top of page

SEMANA 10

#include <iostream>

#include <math.h>

using namespace std;


 

float POTENCIA(int x, double y);

float SERIE(int z);


 

float A, B, SUMA;

 

int main() {

    int opcion = 0, n = 0, base = 0, fact = 1;

    double exponente = 0.0;

 

    do {

        cout << "M E N U\n";

        cout << "----------\n";

        cout << "1. POTENCIA\n";

        cout << "2. SERIE\n";

        cout << "3. PROSUPUESTO\n";

        cout << "4. PROPONGO\n";

 

        cout << "Ingrese una opcion <> 0: ";

        cin >> opcion;

 

        switch (opcion) {

            case 1: {

                cout << "Ingrese base y exponente: ";

                cin >> base >> exponente;

                A = POTENCIA(base, exponente);

                cout << "El resultado de la potencia es: " << A << endl;

                break;

            }

            case 2: {

                cout << "SERIE\n";

                cout << "Cuantos términos ingresar: ";

                cin >> n;

                B = SERIE(n);

                cout << "El resultado de la serie es: " << B << endl;

                break;

            }

            default:

                break;

        }

    } while (opcion != 0);

 

    return 0;

}

 

// Function definitions

float POTENCIA(int x, double y) {

    return pow(x, y);

}

 

float SERIE(int z) {

    int c;

    float B;

    SUMA = 0.0;

    for (c = 1; c <= z; c++) {

        B = 2 + pow(c, c);

        SUMA = SUMA + (1.0 / B);

    }

    return SUMA;

}

TRABAJO DE SUMA DE CUBOS

#include <iostream>

#include <math.h>

using namespace std;

 

// Function declarations

float POTENCIA(int x, double y);

float SUMA_CUBOS(int n);

 

// Global variables

float A, B;

 

int main() {

    int opcion = 0, n = 0, base = 0;

    double exponente = 0.0;

 

    do {

        cout << "M E N U\n";

        cout << "----------\n";

        cout << "1. POTENCIA\n";

        cout << "2. SUMA DE CUBOS\n";

        cout << "3. PROSUPUESTO\n";

        cout << "4. PROPONGO\n";

 

        cout << "Ingrese una opcion <> 0: ";

        cin >> opcion;

 

        switch (opcion) {

            case 1: {

                cout << "Ingrese base y exponente: ";

                cin >> base >> exponente;

                A = POTENCIA(base, exponente);

                cout << "El resultado de la potencia es: " << A << endl;

                break;

            }

            case 2: {

                cout << "SUMA DE CUBOS\n";

                cout << "Ingrese el valor de n: ";

                cin >> n;

                B = SUMA_CUBOS(n);

                cout << "El resultado de la suma de los cubos es: " << B << endl;

                break;

            }

            default:

                break;

        }

    } while (opcion != 0);

 

    return 0;

}

 

// Function definitions

float POTENCIA(int x, double y) {

    return pow(x, y);

}

 

float SUMA_CUBOS(int n) {

    float suma = 0.0;

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

        suma += pow(i, 3);

    }

    return suma;

}

© 2035 por Federico Alonso. Creado con Wix.com
 

  • Twitter Classic
  • Facebook Classic
bottom of page