Está en la página 1de 4

Ejercicio # 1 tabla para sumar números enteros

#include <iostream>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv)

int num, lim, i, result;

cout << "--ALGORITMO TABLA DE SUMAR --" << endl;

cout << "INGRESE EL NUMERO DE LA TABLA: ";

cin >> num;

cout << "INGRESE EL LIMITE DE LA TABLA: " << endl;

cin >> lim;

i = 1;

while (i <= lim)

result = num + i;

cout << num << "+" << i << "=" << result << endl;

i++;

return 0;

}
Ejercicio # 2 primeros cien números impares
#include <iostream>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv)

int i, cont = 0, acum = 0;

i = 199;

while (i >= 1)

if (i % 2 != 0)

cont = cont + 1;

acum = acum + i;

cout << i << endl;

i--;

cout << "la cantidad de numeros generados es:" << cont << endl;

cout << "la sumatoria de numeros generados es:" << acum << endl;

return 0;

También podría gustarte