You are on page 1of 10

Practica N02 Ejercicio n 1:

#include<math.h> #include<iostream.h> void main() { float x,y; cout <<"Ingrese x:"; cin>>x; if(x<=11) y=(3*x)+36; else if(11<x && x<=33) y=pow(x,2)-10; else if(33<x && x<=64) y=x+6; else if(x>64) y=0; cout <<"El valor de y es:"<<y; }

Profesora:
#include<math.h> #include<iostream.h> void main() { float x,y; cout <<"Ingrese x:"; cin>>x; if(x<=11) y=3*x+36; if(x>11 && x<=33) y=pow(x,2)-10; if(x>33 && x<=64) y=x+6; if(x>64) y=0; cout <<"El valor de y es:"<<y; }

Ejercicio n 2: MOSTRAR EL VALOR MAS ALTO DE TRES VALORES INGRESADOS


#include<iostream.h> void main() { float x,y,z; cout <<"Ingrese los tres numeros:"; cin>>x>>y>>z; if(x>y && x>z) cout<<"el mayor es="<<x; if(y>x && y>z) cout<<"el mayor es="<<y; if(z>x && z>y) cout<<"el mayor es="<<z; }

Ejercicio n 3: INGRESAR 3 VALORES E INDICAR SI LOS 3 SON IGUALES O SI HAY DOS IGUALES O SI LOS TRES SON DISTINTOS.
#include<iostream.h> void main() { float x,y,z; cout<<"ingrese los tres numeros:"; cin>>x>>y>>z; if(x==y && x==z) cout<<"los 3 son iguales"<<x; if(x==y && x!=z || x==z && x!=y || y==z && y!=x) cout<<"hay 2 numeros iguales:"<<x; if(x!=y && x!=z && y!=z) cout<<"los 3 nummeros son diferentes"; }

#include<iostream.h> void main() { float x,y,z; cout<<"ingrese los tres numeros:"; cin>>x>>y>>z; if(x==y && x==z) cout<<"los 3 son iguales"<<x; else if(x==y || x==z || y==z) cout<<"hay dos iguales"; else cout<<"los 3 son diferentes"; }

Comandos usados: == : comparar dos numeros != : significa que los dos nuemeros no son iguales /* #include<math.h> #include<iostream.h> void main() {

float x,y; cout<<"Ingrese el valor de X:"; cin>>x; if(x<=11) y=3*x+36; else if(11<x && x<=33) y=pow(x,2)-10; else if(33<x && x<=64) y=x+6; else if(x>64) y=0; cout<<"El valor de Y es:"<<y<<endl; } */

/* #include<math.h> #include<iostream.h> void main() { float x,y; cout<<"Ingrese el valor de X:"; cin>>x;

if(x<=11) y=3*x+36; if(11<x && x<=33) y=pow(x,2)-10; if(33<x && x<=64) y=x+6; if(x>64) y=0; cout<<"El valor de Y es igual a:"<<y<<endl; } */

/* #include<math.h> #include<iostream.h> void main() { float x,y; cout<<"Ingrese el valor de X:"; cin>>x; if(x<=11) y=3*x+36; else if(x<=33) y=pow(x,2)-10; else

if(x<=64) y=x+6; else y=0; cout<<"El valor de Y es:"<<y<<endl; } */

/* #include<iostream.h> void main() { float x,y; cout<<"Ingrese el valor de X:"; cin>>x; if(x<=11) y=3*x+36; else if(x<=33) y=x*x -10; else if(x<=64) y=x+6; else y=0;

cout<<"El valor de Y es:"<<y<<endl<<"!!ESO ES VERDURA!!"<<endl; } */

/* 2 Mostrar el valor mas alto de 3 valores ingresados */

/* #include<math.h> #include<iostream.h> void main() { float x,y,z; cout<<"Ingrese los tres valores:"; cin>>x>>y>>z; if(x>y && x>z) cout<<"El valor mas alto es:"<<x<<endl; if(y>x && y>z) cout<<"El valor mas alto es:"<<y<<endl; if(z>x && z>y) cout<<"El valor mas alto es:"<<z<<endl; } */

/* #include<math.h> #include<iostream.h> void main() { float x,y,z; cout<<"Ingrese los tres valores:"; cin>>x>>y>>z; if(x>y && x>z) cout<<"El valor mas alto es:"<<x<<endl; if(y>x && y>z) cout<<"El valor mas alto es:"<<y<<endl; if(z>x && z>y) cout<<"El valor mas alto es:"<<z<<endl; } */

/* 3 Ingresar 3 valores e indicar si los 3 son iguales, si hay 2 iguale om si los 3 son diferentes */

/* #include<math.h>

#include<iostream.h> void main() { float x,y,z; cout<<"Ingrese los tres valores:"; cin>>x>>y>>z; if(x==y && x==z); cout<<"Los 3 valores son iguales"<<endl; if(x==y && x!=z||x==z && x!=y||y==z && y!=x); cout<<"Existen 2 valores iguales"<<endl; if(x!=y && y!=z && x!=z) cout<<"Los 3 valores son diferentes"<<endl; } */

#include<iostream.h> void main() { float x,y,z; cout<<"ingrese los tres numeros:"; cin>>x>>y>>z; if(x==y && x==z) cout<<"los 3 son iguales"; if(x==y && x!=z || x==z && x!=y || y==z && y!=x) cout<<"hay 2 numeros iguales:"; if(x!=y && x!=z && y!=z)

cout<<"los 3 nummeros son diferentes"; }

You might also like