Sunday, August 23, 2015

Greatest of 3 Numbers using Nested Conditional Statement

 Q. 85. Program to input 3 numbers and print the greatest of three numbers using nested conditional statement.



Copy Code:

#include<iostream>
using namespace std;
int main()
{
  int a, b, c ;
  cout << "Enter 3 numbers : "; cin >> a >> b >> c;
  if (a>b)
   {
     if (a>c)
        cout <<a << " is greatest number";
     else
        cout <<c << " is greatest number";
   }
  else
  {
     if (b>c)
        cout << b << " is greatest number";
     else
        cout << c << " is greatest number";
   }
   return(0);
}



No comments:

Post a Comment