[COCO TEEN BLOG]

martes, 22 de marzo de 2016

25% Exam

Exercise: The user had to enter 3 number, then the program should organize it in order ascendent to descendent.

This is my programming code:

#include <iostream>
using namespace std;

int main()
{
  int n1,n2,n3;
  cout<<"Enter the first number";
  cin>>n1;
  cout<<"Enter the second number";
  cin>>n2;
  cout<<"Enter the third number";
  cin>>n3;
  if((n1>n2)&&(n2>n3)&&(n3<n1)){
  cout<<n1<<endl;
  cout<<n2<<endl;
  cout<<n3<<endl;
}
else
{
  if((n1>n2)&&(n2<n3)&&(n3<n1)){
  cout<<n1<<endl;
  cout<<n3<<endl;
  cout<<n2<<endl;
}
else
{
  if((n1<n2)&&(n2>n3)&&(n3<n1)){
  cout<<n2<<endl;
  cout<<n1<<endl;
  cout<<n3<<endl;
}
else
{
  if((n1<n2)&&(n2>n3)&&(n3>n1)){
  cout<<n2<<endl;
  cout<<n3<<endl;
  cout<<n1<<endl;
}
else
{
  if((n1>n2)&&(n2<n3)&&(n3>n1)){
  cout<<n3<<endl;
  cout<<n1<<endl;
  cout<<n2<<endl;
}
else
{
  if((n1<n2)&&(n2<n3)&&(n3>n1)){
  cout<<n3<<endl;
  cout<<n2<<endl;
  cout<<n1<<endl;
}
}
}
}
}
}
  return 0;
}


No hay comentarios:

Publicar un comentario

Cute Bow Tie Hearts Blinking Blue and Pink Pointer