#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int cantidad;
    int numero;
    int contPares = 0, contImpares = 0;
    int sumaPares = 0, sumaImpares = 0;

    srand(time(0));

    cout << "¿Cuántos números aleatorios desea generar?: ";
    cin >> cantidad;

    cout << "\nNúmeros generados:\n";

    for (int i = 1; i <= cantidad; i++) {
        numero = rand() % 100 + 1; // Genera números entre 1 y 100

        cout << numero << " ";

        if (numero % 2 == 0) {
            contPares++;
            sumaPares += numero;
        } else {
            contImpares++;
            sumaImpares += numero;
        }
    }

    cout << "\n\nRESULTADOS\n";
    cout << "------------------------\n";
    cout << "Cantidad de números pares: " << contPares << endl;
    cout << "Suma de números pares: " << sumaPares << endl;

    cout << "Cantidad de números impares: " << contImpares << endl;
    cout << "Suma de números impares: " << sumaImpares << endl;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: