Read OnLine Cpp Program Example
3 - CONDITIONAL STATMENT | |
---|---|
PRAC 1 | PRAC 2 |
//wap to print Greater number #include<iostream.h> #include<conio.h> void main() { int a,b; clrscr(); cout<<"Enter 1st number:"; cin>>a; cout<<"Enter 2nd number:"; cin>>b; if (a>b) { cout<<"1st number greater then 2nd number"; } else { cout<<"2nd number greater then 1st number"; } getch(); } -----output------ Enter 1st number:5 Enter 2nd number:4 1st number greater then 2nd number |
//wap to print Equal number #include<iostream.h> #include<conio.h> void main() { int a,b; clrscr(); cout<<"Enter 1st number:"; cin<<a; cout<<"Enter 2nd number:"; cin>>b; if (a>b) { cout<<"1st number greater then 2nd number"; } else if (b>a) { cout<<"2nd number greater then 1st number"; } else { cout<<"Both number are equal"; } getch(); } ------output------- Enter 1st number:5 Enter 2nd number:5 Both number are equal |
Previous | Next |
Download | Download |