Guìa1ProgramacionenC++
Enviado por Memo CG • 2 de Julio de 2018 • Tarea • 1.654 Palabras (7 Páginas) • 72 Visitas
1. // Programa que muestra operaciones matematicas de 3 números ingresados por el usuario.
#include <iostream>
using namespace std;
main (){
float n1,n2,n3,suma,multi,prom;
cout << "Ingrese tres enteros distintos: "; cin >> n1;cin >> n2;cin >> n3;
suma=n1+n2+n3;
prom=(n1+n2+n3)/3;
multi=n1*n2*n3;
cout << "\n\t1. La suma es: ";cout << suma;
cout << "\n\t2. El promedio es: ";cout << prom;
cout << "\n\t3. El producto es: ";cout << multi;
if ( n1<n2 && n1<n3){
cout << "\n\t4. El menor es: "; cout << n1;
}
if ( n2<n1 && n2<n3){
cout << "\n\t4. El menor es: "; cout << n2;
}
if ( n3<n2 && n3<n1){
cout << "\n\t4. El menor es: "; cout << n3;
}
if ( n1>n2 && n1>n3){
cout << "\n\t5.:El mayor es: ";cout << n1;}
if ( n2>n3 && n2>n3){
cout << "\n\t5.:El mayor es: ";cout << n2;}
if ( n3>n2 && n3>n1){
cout << "\n\t5.:El mayor es: ";cout << n3;}
return 0;
}
2.// Programa que pide 2 enteros al usuarios y diga cuál es máss grande o si son iguales.
#include <iostream>
using namespace std;
main (){
int n1, n2;
cout << "Ingrese dos enteros: ";cin >> n1; cin >> n2;
if (n1>n2){
cout << "\n";cout << n1; cout << " es más grande.";
}if (n2>n1) {
cout << "\n";
cout << n2; cout << " es más grande";
}else{
cout << "\n";
cout << "Estos números son iguales.";
}
return 0;
}
3. /* Figuras geometricas*/
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout <<"\n";
cout << " " <<"*********" << " " << "***" << " " << "*" << " " << "*" << "\n";//1
cout << " " <<"* *" << " " << "* *" << " " << "***" << " " << "* *" << "\n";//2
cout << " " <<"* *" << " " << "* *" << " " << "*****" << " " << "* *" << "\n";//3
cout << " " <<"* *" << " " << "* *" << " " << " * " << " " << "* *" << "\n";//4
cout << " " <<"* *" << " " << "* *" << " " << " * " << " " << "* *" << "\n";//5
cout << " " <<"* *" << " " << "* *" << " " << " * " << " " << "* *" << "\n";//6
cout << " " <<"* *" << " " << "* *" << " " << " * " << " " << "* *" << "\n";//7
cout << " " <<"* *" << " " << "* *" << " " << " * " << " " << "* *" << "\n";//8
cout << " " <<"*********" << " " << "***" << " " << " * " << " " << "*" << "\n";//9
return 0;
}
4. // Programa que muestra el mayor y menor de 5 números ingresados por el usuario.
#include <iostream>
using namespace std;
int main (){
int n1,n2,n3,n4,n5;
...