Saturday, 7 February 2015

Write a Program in C++ to find the Greatest Number out of two number using if-else statement.

This is the Selection Structure that performs one out of two or more Statements depending upon the Condition. Mean here according to the Condition (a>b) a is Greater then it will Print the first Statement and if b is Greater then it will Print the second Statement.

 #include<iostream.h>

  #include<conio.h>

  void main()
 {
 int a,b;

 cout<<"enter the values of a and b";

 cin>>a>>b;

 if(a>b)

 {
cout<<"\n Greater no is : "<<a;


 }

 else

 {

cout<<"\n greater number is : "<< b;

 }

getch();

 }


OUTPUT WILL BE: 



2 comments: