top of page

Tercera Práctica Calificada

# include <iostream>
# include <math.h>
# include <conio.h>
using namespace std;
int Opcion;
double A,B,Xc,Xl,Z,R,L,C,W,P,Vx,Vy,V,Vector;
int n1,n2, Mayor, numMAX;
float IMPEDANCIA(double x, double y, double z);
float PHASE(double p, double q, double r);
int encontrarMAX(int x, int y);
float VECTOR(float x, float y);
int main()
{
do
{
cout << "\n    MENU DE FUNCIONES"<< endl;
cout << " ----------------------------"<< endl;
cout << "  [1] CALCULO DE LA IMPEDANCIA"<< endl;
cout << "  [2] CALCULO DE FASE"<< endl;
cout << "  [3] MAYOR DE 2 NUMEROS "<< endl;
cout << "  [4] CALCULO DEL VECTOR A PARTIR DE SUS COMPONENTES "<< endl;
cout << "\n  INGRESE UNA OPCION <> 0 : ";
cin>>Opcion;
switch (Opcion)
{
case 1:
   {
   cout << " \n  IMPEDANCIA \n";
   cout << " ---------------------- \n";
   cout <<"  Ingrese la resistencia R: "; cin>>R;
   cout <<"  Ingrese la inductancia L: "; cin>>L;
   cout <<"  Ingrese la capacitancia C: "; cin>>C;
   cout <<"  Ingrese la velocidad angular W: "; cin>>W;
   Xc=1/(W*C);
   Xl= W*L;
   A = IMPEDANCIA (R,Xl,Xc);
   cout<<"  La impedancia es: " <<A<<endl;
   } break;  
case 2:
   {
   cout << " \n  CALCULO DE FASE \n";
   cout << " ---------------------- \n";
   cout <<"  Ingrese la reactancia inductiva Xl: "; cin>>Xl;
   cout <<"  Ingrese la inductancia capativa Xc: "; cin>>Xc;
   for (R=10; R<=20; R=R+0.5)
   {
     B = PHASE (R,Xl,Xc);
     cout<<"  LA FASE PHI:" <<B<<" PARA R= "<<R<<endl;
   }
   } break; 
case 3:
   {
   cout << " \n  MAYOR DE 2 NUMEROS \n";
   cout << " ---------------------- \n";
   cout <<"  Ingrese el primer numero: "; cin>>n1;
   cout <<"  Ingrese el segundo numero: "; cin>>n2;
   Mayor = encontrarMAX (n1,n2);
   cout<<"  El mayor de los 2 numeros es:" <<Mayor<<endl;
   } break; 
case 4:
   {
   cout << " \n  CALCULO DEL VECTOR A PARTIR DE SUS COMPONENTES \n";
   cout << " ------------------------------------------------- \n";
   cout <<"  Ingrese la componente x del vector: "; cin>>Vx;
   cout <<"  Ingrese la componente y del vector: "; cin>>Vy;
   V = VECTOR (Vx,Vy);
   cout<<"  El valor del vector es:" <<V<<endl;
   } break;     
}// fin del switch
 
} while(Opcion !=0);
 

} //FIN DEL PROGRAMA

// ZONA DE DESARROLLO DE FUNCIONES
float IMPEDANCIA(double x, double y, double z)
{
Z = sqrt(pow(x,2)+pow((y-z),2));
return Z;

float PHASE(double p, double q, double r)
{
P = atan((q-r)/p);
return P;

int encontrarMAX(int x, int y)
{
   
   if(x>=y)
   { 
     numMAX = x;
   }
   else {
     numMAX = y;
   } 
   return numMAX; 
}
float VECTOR(float x, float y)
{
Vector= sqrt(pow(x,2)+pow(y,2));
return Vector;
}

IMPEDANCIA

CALCULO DE LA IMPEDANCIA FUNCIONES.jpg

ÁNGULO DE FASE

CALCULO DE ANGULO DE FASE FUNCIONES.jpg

MAYOR DE 2 NÚMEROS

MAYOR DE 2 NUMEROS FUNCIONES.jpg

CÁLCULO DEL MÓDULO DEL VECTOR

CALCULO DE VECTOR 2 FUNCIONES.jpg
bottom of page