Está en la página 1de 5

TALLER #5

NOMBRE DE LOS INTEGRANTES: Christopher Aparicio (9-765-2174)


José Romero (9-764-2278)

GRUPO: 4IE701

PROGRAMA #1: SUMA DE DOS VALORES

#include <iostream>
using namespace std;

int main ()
{
int val_1 , val_2 , suma; //SE DEFINEN LAS VARIABLES

cout << "\t\tESTE PROGRAMA REALIZARA UNA SUMA DE DOS VALORES INTRODUCIDOS\n\
n";
//SE PREGUNTA POR EL PRIMER VALOR
cout << " Para Empezar, Introduzca el Primer Valor ";
cin >> val_1;
// SE PREGUNTA POR EL SEGUNDO VALOR
cout << "\n\n Introduzca su Segundo Valor: ";
cin >> val_2;

// SE REALIZA LA OPERACION
suma = val_1 + val_2;

cout << "\n\n\tEL RESULTADO DE LA SUMA ES: " << suma; // MUESTRA EL MENSAJE
DEL RESULTADO

return 0;
}

-----------------------------------------------------------------------------------
--
PROGRAMA #2: LEER NOMBRE COMPLETO

//CON ESTE PROGRAMA PODRA IMPRIMIR EL NOMBRE INTRODUCIDO

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
string nombre; //SE DEFINE LA VARIABLE

cout << "\t\tBIENVENIDO A ESTE PROGRAMA\n"<<endl;

cout << "Podria Introducir su Nombre Completo: "; //SE PREGUNTA POR EL NOMBRE
getline(cin, nombre);
cout << "\n\nBuenos Dias, " << nombre << ", gracias por usar esta
aplicacion."; //SE IMPRIME EL MENSAJE

return 0;
}

-----------------------------------------------------------------------------------
------------
PROGRAMA #3: MAYOR O MENOR DE EDAD

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
int edad=0;
string nombre;

cout << "\t\tCON ESTE PROGRAMA PODRA SABER SI ES MAYOR O MENOR DE EDAD.";
cout << "\n\n INTRODUCE TU NOMBRE COMPLETO: "; //SE PIDE NOMBRE DEL USUARIO
getline (cin, nombre);

cout << "\n\n Muy Bien "<< nombre<< ", Ahora Podrias Introducir tu Edad: ";
cin >> edad; //LUEGO SE PIDE EDAD DEL USUARIO

//SE HACEN LAS CONDICIONES


if (edad >= 18) // PARA CUANDO ES MAYOR
{

cout << "\n\n\tBuenos Dias "<< nombre <<", eres mayor de edad."; //SE
IMPRIME EL MENSAJE
}
else
{
if (edad < 18) //PARA CUANDO ES MENOR
{
cout << "\n\n\tBuenos Dias "<<nombre << ", eres menor de
edad."; //SE IMPRIME EL MENSAJE
}
}

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

return 0;
}

-----------------------------------------------------------------------------------
---------------------------
PROBLEMA #4: USANDO DO_WHILE
/*CON ESTE PROGRAMA USANDO EL do_while
SE PODRA REALIZAR LA SUMA DE 6 VALORES LEIDOS POR EL USUARIO
*/

#include <iostream>
using namespace std;

int main()
{
int cantidad=1;
float valores, suma;

cout << "\n\n\t\tINTRODUCE TUS 6 VALORES PARA REALIZAR LA SUMATORIA: \n\n\n";

do
{
//SE PREGUNTA POR LOS 6 VALORES
cout << "\tTu Valor #"<<cantidad<< ": "; cin >>valores;
cout << endl;
suma = suma + valores;
cantidad ++; //SE COLOCA PARA IR AUMENTANDO LA CANTIDAD DE VECES A
PREGUNTAR

} while (cantidad <= 6); // SE DETENDRA HASTA QUE SE CUMPLA LA CONDICION

cout << "\n\n\t\tEL RESULTADO DE LA SUMATORIA ES: " << suma <<endl;
cout << "\n\n";

return 0;
}

-----------------------------------------------------------------------------------
----
PROBLEMA #4: USANDO WHILE

/*CON ESTE PROGRAMA USANDO EL WHILE


SE PODRA REALIZAR LA SUMA DE 6 VALORES LEIDOS POR EL USUARIO
*/

#include <iostream>
using namespace std;

int main()
{
int cantidad=1;
float valores, suma;

cout << "\n\n\t\tINTRODUCE TUS 6 VALORES PARA REALIZAR LA SUMATORIA: \n\n\n";

while (cantidad <= 6)


{ //SE PREGUNTA POR LOS 6 VALORES
cout << "\tTu Valor #"<<cantidad<< ": "; cin >>valores;
cout << endl;

suma = suma + valores;


cantidad ++; //SE COLOCA PARA IR AUMENTANDO LA CANTIDAD DE VECES A
PREGUNTAR
}

cout << "\n\n\t\tEL RESULTADO DE LA SUMATORIA ES: " << suma <<endl;
cout << "\n\n";

return 0;
}

-----------------------------------------------------------------------------------
------
PROBLEMA #4: USANDO FOR

/*CON ESTE PROGRAMA USANDO EL for


SE PODRA REALIZAR LA SUMA DE 6 VALORES LEIDOS POR EL USUARIO
*/

#include <iostream>
using namespace std;

int main()
{
int cantidad=1 ;
float valores, suma;

cout << "\n\n\t\tINTRODUCE TUS 6 VALORES PARA REALIZAR LA SUMATORIA: \n\n\n";

for (cantidad=1; cantidad <= 6; cantidad ++ ) // ++ SE COLOCA PARA IR


AUMENTANDO LA CANTIDAD DE VECES A PREGUNTAR
{
//SE PREGUNTA POR LOS 6 VALORES
cout << "\tTu Valor #"<<cantidad<< ": "; cin >>valores;
cout << endl;

//SE ACUMULAN LOS VALORES EN LA VARIABLE SUMA


suma = suma + valores;
}

cout << "\n\n\t\tEL RESULTADO DE LA SUMATORIA ES: " << suma <<endl;
cout << "\n\n";

return 0;
}

-------------------------------------------------------------------------------
PROGRAMA #5: FACTORIAL

#include <iostream>
using namespace std;

int main()
{
//SE DEFINEN LAS VARIABLES DE TIPO ENTERO
int valor=0, factor=1;

//PODEMOS DAR UNA INTRODUCCIÓN AL PROGRAMA


cout << "\n\t\tBIENVENIDO A EL SIGUIENTE PROGRAMA";
cout << "\n\n\n El siguiente Programa le permitira calcular el factorial de
un valor introducido.";
cout << "\n\n PARA EMPEZAR, INGRESE EL VALOR DEL FATORIAL QUE DESEA
(ENTERO): "; cin >> valor;

//SE REALIZA LA CONDICIÓN CON for


for (int cont=1; cont <= valor; cont ++)
{
//AQUI SE IRA ACUMULANDO CADA MULTIPLICACIÓN
factor = factor * cont;
}

//SE IMPRIME EN PANTALLA EL RESULTADO


cout << "\n\nEL RESULTADO DEL FACTORIAL ES: "<<factor;

return 0;
}

-----------------------------------------------------------------------------------
----------

También podría gustarte