Pages

Tuesday, August 20, 2013

Write a program of Nested if statements in C++

Nested if in two-way selection

Source Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
   #include <iostream.h>
   #include <conio.h>
   int main()
   {
       cout << "Please enter two integer: ";
       int a, b;
       cin  >> a >> b ;
   if (a <= b)
      if (a < b)
       cout << a << " <  " << b << endl;
   else // equal
       cout << a << " == " << b << endl;
   else // greater than
       cout << a << " >  " << b << endl;  
       
     getch ();  
     return 0;  
                } //main

Result:


Please enter two integer: 46  79
46 <  79

No comments:

Post a Comment