Monday, 16 February 2015

Write a Program in C++ to calculate Sum and Multiplication of Two Numbers if first value is greater then 2nd otherwise Print 'Sorry'.

       In this Program you can see that this is the Program using if else. In which we have to Calculate the Sum of and the Multiplication of Two Numbers using if else Statement, if a is greater then b. Otherwise we have to Print Sorry if b is Greater then a.


        #include<iostream.h>
#include<conio.h>
main()
{
int a,b, sum, mul;

clrscr();

cout<<"enter the value";

cin>>a;
cout<<"enter the 2nd value";
cin>>b;
if(a>b)
{
 sum=a+b;
 mul= a*b;

 cout<<"sum is "<<sum;
 cout<<"\n mul is "<<mul;

 }

else
 {
cout<<"sorry";

 }
getch();


}


The Output will be


No comments:

Post a Comment