[Solved] comparing five integers with if , else if statement


try this :

int main ()
{
int n1, n2, n3, n4, n5, biggest,smallest;
cout << "Enter the five numbers: ";

cin >> n1 >> n2 >> n3 >> n4 >> n5 ;

smallest=biggest=n1;
if(n2>biggest){
    biggest=n2;
}
if(n2<smallest){
      smallest=n2;
}
if(n3>biggest){
   biggest=n3;
}
if(n3<smallest){
      smallest=n3;
}
if(n4>biggest){
    biggest=n4;
}
if(n4<smallest){
      smallest=n4;
}
if(n5>biggest){
     biggest=n5;
}
if(n5<smallest){
      smallest=n5;
}

cout<<smallest<<"\t"<<biggest;

return 0;
}

2

solved comparing five integers with if , else if statement