next up previous
Next: Activity 1 Up: If Statement Previous: If Statement

Example




// This program illustrates the if statement

#include <iostream.h>

main( )
{
int a, b;
cout << "Enter first number" ;
cin >> a;
cout << "Enter Second number" ;
cin >> b;
if(a<b) cout << "First number is less than second $\backslash$n";
if(a==b) cout << "First number is equal to second$\backslash$n";
if(a>b) cout << "First number is greater than second$\backslash$n";
if(a!=b) cout << "First number not equal to second$\backslash$n";

return 0;
}



Yousef Haik
2/23/1998