top of page

FUNCIONES CON PARÁMETROS

#include <iostream>
#include <math.h>

using namespace std;
int Opcion;
double A,B,P,Xc, Xl, Z, R, L, C, w,a,b;
float IMPEDANCIA (double x, double y, double z); // 2.ASIGNACIOON
float PHASE (double p, double q, double r);
int area_rectangulo(int a,int b);
void potencia(int x,int y,int z);

int main()
{
  do
  {
cout<<"   M E N U   \n";
cout<<"------------   \n";
cout<<"1.- Calculo de la IMPEDANCIA  \n";
cout<<"2.- CALCULO DE FASE  \n";
cout<<"3.- PLANTEADO 1  \n";
cout<<"4.- PLANTEADO 2  \n";
            cout<<"INGRESE UNA OPCION <> 0: "; cin>>Opcion;
switch (Opcion)
{
  case 1:
    {
    cout<<endl;
       cout<<"1.- CALCULO DE IMPEDANCIA   \n";        
       cout<<"Ingrese la resistencia R = "; cin>>R; 
   cout<<"Ingrese la inductancia L = "; cin>> L; 
   cout<<"Ingrese la capacitanica C = "; cin>> C; 
   cout<<"Ingrese la veloc angular w = "; cin>>w;
    Xc = 1/(w*C);
    Xl = w*L;
       B = IMPEDANCIA (R, Xl, Xc); // 1. INVOCACION
     cout<<"La impedancia Z = "<<B; //5. respuesta 
       cout<<endl;
    }; break;
    
   case 2:
    {
       cout<<"2.- CALCULO DE FASE \n";              
       cout<<endl;
       cout<<endl;
       cout<<"1.- CALCULO DE IMPEDANCIA   \n";        
       cout<<"Ingrese la reactancia inductiva Xl = "; cin>>Xl; 
   cout<<"Ingrese la reactancia capacitiva Xc = "; cin>>Xc; 
       
   for (R=10; R<=20; R = R + 0.5)
   {
         A = PHASE (R, Xl, Xc); // 1. INVOCACION
       cout<<"La FASE ES PHI = "<<A<<"PARA R="<<R; //5. respuesta 
       cout<<endl;
   }
    }; break;
    
   case 3:
       {
           cout<<"3.-AREA RECFTANGULO \n";
           cout<<"ingrese el ladi 1: "; cin>>a;
           cout<<"ingrese el ladi 2: "; cin>>b;
           A=area_rectangulo(a,b);
           cout<<"EL AREA DEL RECTANGULO ES :"<<A<<endl;
           cout<<endl;
       }; break;
   case 4:
       {
           cout<<"4.-POTENCIA \n";
           int base,exponente,resultado;
           cout<<"ingrese la base:"; cin>>base;
           cout<<"ingrese el exponente :"; cin>>exponente;
           potencia(base,exponente,resultado);
           cout<<"el resultado de la potencia es:"<<resultado<<endl;
           cout<<endl;
       }; break;

       cout<<endl;

//Fin del caso 5
    
  } // fin del switch
} while (Opcion!=0); // FIN DEL DO WHILE

} // FIN PROGRAMA
//-----------------------------------------------------
float IMPEDANCIA (double x, double y, double z) //3.
{
   Z = sqrt (pow(x,2)+pow((y-z),2));
   return Z;//4.
}

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

int area_rectangulo(int lado1 ,int lado2)
{
return lado1*lado2;    
}
void potencia (int base, int exponente, int resultado)
{
   resultado=pow(base,exponente);
}

bottom of page