Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lista de programas

454 views

Published on

  • Be the first to comment

  • Be the first to like this

Lista de programas

  1. 1. Programa#1<br />#include<iostream.h>void mayor(){     int n1, n2;     cout << "numero 1: "; cin >> n1;     cout << "numero 2: "; cin >> n2;     if (n1>n2)     {     cout<<endl<<"el numero mayor es: "<<n1<<endl;     cout<<"el número menor es: "<<n2;     }     else     {     cout<<endl<<"el numero mayor es: "<<n2<<endl;     cout<<"el número menor es: "<<n1;     }}int main(){     mayor();} <br />Programa#2<br />#include<iostream.h>void mayor(int n1, int n2){     if (n1>n2)     {     cout<<endl<<"el numero mayor es: "<<n1<<endl;     cout<<"el numero menor es: "<<n2;     }     else     {     cout<<endl<<"el numero mayor es: "<<n2<<endl;     cout<<"el numero menor es: "<<n1;     }}int main(){     int n1, n2;     cout << "numero 1: "; cin >> n1;     cout << "numero 2: "; cin >> n2;     mayor(n1, n2);}<br />Programa#3<br />#include<iostream.h>int mayor (){     int n1, n2,r;     cout << "numero 1: "; cin >> n1;     cout << "numero 2: "; cin >> n2;     if (n1>n2)     {     r=n1;     }     else     {     r=n2;     }     return r;}int main(){     int r;     r=mayor();     cout<<endl<<"el numero mayor es: "<<r;}<br />Programa#4<br />#include<iostream.h>int mayor(int n1, int n2){     int r;     if (n1>n2)     {     r=n1;     }     else     {     r=n2;     }     return r;}int menor(int n1, int n2){     int m;     if (n1<n2)     {     m=n1;     }     else     {     m=n2;     }     return m;}int main(){     int n1, n2, r,m;     cout << "numero 1: "; cin >> n1;     cout << "numero 2: "; cin >> n2;     r = mayor(n1, n2);     m=menor(n1,n2);     cout <<endl<< "el numero mayor es: " << r<<endl;     cout << "el número menor es: " << m;}<br />En la forma adicional quedaría de la siguiente manera<br />#include<iostream.h>int mayor(int n1, int n2){     int r;     if (n1>n2)     {     r=n1;     }     else     {     r=n2;     }     return r;}int menor(int n1, int n2){     int m;     if (n1<n2)     {     m=n1;     }     else     {     m=n2;     }     return m;}int main(){     int n1, n2;     cout << "numero 1: "; cin >> n1;     cout << "numero 2: "; cin>> n2;     cout <<endl<< "el numero mayor es " << mayor(n1, n2)<<endl;     cout << "el numero menor es " << menor(n1, n2);} <br />

×