Final.LP

4
1. Dado dos números enteros determine cuál es el mayor. #include <cstdlib> #include <iostream> using namespace std; int main() { float a,b; cout<<" Ingrese el primer numero "<<endl; cin>>a; cout<<" Ingrese el segundo numero "<<endl; cin>>b; if(a>b) cout<<" El numero mayor es :"<<a<<endl; else cout<<" El numero mayor es :"<<b<<endl; system("PAUSE"); return EXIT_SUCCESS; } 2. Determine el mayor de tres números enteros. #include <cstdlib> #include <iostream> using namespace std; int main() { int a,b,c; cout<<" Ingrese el primer numero "<<endl; cin>>a; cout<<" Ingrese el segundo numero "<<endl; cin>>b; cout<<" Ingrese el tercer numero "<<endl; cin>>c; if(a>b && b>c) cout<<" El numero mayor es :"<<a<<endl; else if(c>b && b>a) cout<<" El numero mayor es :"<<c<<endl; else cout<<" El numero mayor es :"<<b<<endl;

description

Final.LP

Transcript of Final.LP

Page 1: Final.LP

1. Dado dos números enteros determine cuál es el mayor.

#include <cstdlib>#include <iostream>

using namespace std;int main(){ float a,b; cout<<" Ingrese el primer numero "<<endl; cin>>a; cout<<" Ingrese el segundo numero "<<endl; cin>>b; if(a>b) cout<<" El numero mayor es :"<<a<<endl; else cout<<" El numero mayor es :"<<b<<endl; system("PAUSE"); return EXIT_SUCCESS;}

2. Determine el mayor de tres números enteros.

#include <cstdlib>#include <iostream>

using namespace std;

int main(){ int a,b,c; cout<<" Ingrese el primer numero "<<endl; cin>>a; cout<<" Ingrese el segundo numero "<<endl; cin>>b; cout<<" Ingrese el tercer numero "<<endl; cin>>c; if(a>b && b>c) cout<<" El numero mayor es :"<<a<<endl; else if(c>b && b>a) cout<<" El numero mayor es :"<<c<<endl; else cout<<" El numero mayor es :"<<b<<endl; system("PAUSE"); return EXIT_SUCCESS;}

Page 2: Final.LP

3. Reclutas para el ejercito del Perú

#include <cstdlib>#include <iostream>

using namespace std;

int main(){

string nombre; float edad, estatura, peso; cout<<" Ingrese el nombre del recluta "<<endl; cin>>nombre; cout<<" Ingrese la edad"<<endl; cin>>edad; if (edad>=21 || edad<=17) cout<<"NO CUMPLE CON LAS CARACTERISTICAS"<<endl; else { cout<<"ingrese la estatura en centimetros"<<endl; cin>>estatura; if(estatura<=158) cout<<" NO CUMPLE CON LAS CARACTERISTICAS "<<endl; else { cout<<"ingrese el peso"<<endl; cin>>peso; if(peso>=90) cout<<" NO CUMPLE CON LAS CARACTERISTICAS "<<endl; else cout<<"Nombre: "<<nombre <<endl ; cout<<"Edad: "<<edad<<endl ; cout<<"Estatura: "<<estatura <<endl ; cout<<"Peso: "<<Peso <<endl ; cout<<"FELICITACIONES, Ud cumple con las características para ser enrolado al ejercito del Perú”<<endl; } } system("PAUSE"); return EXIT_SUCCESS;}

Page 3: Final.LP

4. Cree un programa que calcule el resultado de la siguiente función

3*Y+36 SI 0<Y≤10

Y2-10 SI 10<Y≤20

Y3+Y2-1 SI 20<Y≤30

0 para cualquier otro valor

#include <cstdlib>#include <iostream>

using namespace std;int main(){ int x,y; cout<<" Ingrese el valor de y "<<endl; cin>>y; if(y>0 && y<=10) {x=3*y+36; cout<< "el valor de x es:"<< x<<endl;} else if(y>10 && y<=20) {x=y*y-10; cout<< "el valor de x es:"<< x<<endl;} else if(y>20 && y<=30) {x=y*y*y+y*y-1; cout<< "el valor de x es:"<< x<<endl;} else cout<< "el valor de x es:"<<0<<endl; system("PAUSE"); return EXIT_SUCCESS;}

X=