top of page

Semana 12-FUNCIONES CON PARÁMETROS

#include <iostream>

#include <math.h> // Para funciones matemáticas

 

using namespace std;

 

// Función para mostrar el menú

void mostrarMenu() {

    cout << "Menú:" << endl;

    cout << "1. Tabla de multiplicar" << endl;

    cout << "2. Mayor de tres números" << endl;

    cout << "3. Mayor de tres números variando L" << endl;

    cout << "4. Mayor de tres números variando L y C" << endl;

    cout << "0. Salir" << endl;

}

 

// Función para calcular la tabla de multiplicar

void tablaMultiplicar() {

    int numero;

    cout << "Ingrese un número para mostrar su tabla de multiplicar: ";

    cin >> numero;

    for (int i = 1; i <= 10; ++i) {

        cout << numero << " x " << i << " = " << numero * i << endl;

    }

}

 

// Función para encontrar el mayor de tres números

void mayorTresNumeros() {

    int a, b, c;

    cout << "Ingrese tres números: ";

    cin >> a >> b >> c;

    int mayor = max(max(a, b), c);

    cout << "El mayor de los tres números es: " << mayor << endl;

}

 

// Función para encontrar el mayor de tres números variando L

void mayorTresNumerosVariandoL() {

    // Implementa aquí tu lógica

}

 

// Función para encontrar el mayor de tres números variando L y C

void mayorTresNumerosVariandoLC() {

    // Implementa aquí tu lógica

}

 

int main() {

    int opcion;

    do {

        mostrarMenu();

        cout << "Seleccione una opción (0-4): ";

        cin >> opcion;

        switch (opcion) {

            case 1:

                tablaMultiplicar();

                break;

            case 2:

                mayorTresNumeros();

                break;

            case 3:

                mayorTresNumerosVariandoL();

                break;

            case 4:

                mayorTresNumerosVariandoLC();

                break;

            case 0:

                cout << "¡Hasta luego!" << endl;

                break;

            default:

                cout << "Opción inválida. Intente nuevamente." << endl;

        }

    } while (opcion != 0);

 

    return 0;

}

#include <iostream>
#include <math.h>
using namespace std;
int Opcion;
double A, B, P,Xc, Xl, Z, R, L, C, w;
int d, CUADRADO;
int q,e,v, multiplica(int x, int y);
float IMPEDANCIA (double x, double y, double z);
float PHASE (double p, double q, double r);
float cuadrado(float r);

int main()
{
  do
  {
cout<<"   M E N U  de FUNCIONES  \n";
cout<<"------------   \n";
cout<<"1.- CALCULO DE IMPEDANCIA  \n";
cout<<"2.- CALCULO DE FASE  \n";
cout<<"3.- PLANTEADO CUADRADOS\n";
cout<<"4.- CAUDAL \n";
 
    cout<<"INGRESE UNA OPCION <> 0: "; cin>>Opcion;
switch (Opcion)
{
  case 1:
    {
       cout<<"1.- CALCULO DE IMPEDANCIA \n";
       cout<<"ingrese la resistencia R = "; cin>>R;
       cout<<"ingrese la inductancia L = "; cin>>L;
       cout<<"ingrese la capacitancia C = "; cin>>C;
       cout<<"ingrese el valocidad angular w = "; cin>>w;
       Xc = 1/(w*C);
       Xl = w*L,
       B = IMPEDANCIA (R, Xl, Xc);
         cout<<"La impedancia Z = "<<B;
       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);
          cout<<"La FASE ES PHI = "<<A<<"PARA R="<<R;
          cout<<endl;
     }
    }; break;
    
   case 3:
   {
  cout<<"3.- PLANTEADO CUADRADOS\n";
   cout<<"Ingrese un numero"; cin>>d;
   cout<<"El cuadrado del numero es:"<<cuadrado(d)<<endl;
   cout<<endl;
    }; break;
    
   case 4:
   {
cout<<"4.- SU LIBRO CAUDAL \n";
   cout<<"Ingrese el Area de la seccion transversal" ; cin>>e;
   cout<<"Ingrese la velocidad del agua (en metros por segundo)"; cin>>v;
   q = e*v;
   cout<<"El valor del caudal es:"<<q<<endl;
   cout<<endl;    
    }; break; 
   
  } // fin del switch
} while (Opcion!=0); // FIN DEL DO WHILE

} // FIN PROGRAMA

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;
}

float cuadrado(float r)
{
   float c = r*r;
   return c;
}


float multiplica(int x)
{
   float q = e*v;
   return q;
}

LENGUAJE DE PROGRAMACIÃ’N

©2023 por LENGUAJE DE PROGRAMACIÒN. Creado con Wix.com

bottom of page