Question #4838

write a program that ask the user to enter two numbers. the program should use the conditional operator to determine which number is the smaller and which is the larger.

Expert's answer


#include <iostream.h>
#include <conio.h>
main(){
int a,b;
cout<<"Enter number a:";
cin>>a;
cout<<"Enter number b:";
cin>>b;
if (a>b) cout<<"a is larger than b";
if (a<b) cout<<"b is larger than a";
if (a==b) cout<<"a is equal b";
getch();
}
LATEST TUTORIALS
APPROVED BY CLIENTS