Saturday, December 5, 2009

C++->SUM DIFFERENCE PRODUCT AND QUOTIENT

Write a program to find the sum, difference, product and quotient of two numbers using C++

#include
#include
#include
void main()
{
char ch;
float a,b,r;
clrscr();
cout<<”\n1. Sum”; cout<<”\n2. Difference”; cout<<”\n3. Product”; cout<<”\n4. Quotient”; cout<<”\n\nEnter your choice……”; ch=getchar(); switch(ch) { case ‘1’: cout<<”Enter two numbers : “; cin>>a>>b;
r=a+b;
cout<<”Sum : “<>a>>b;
r=a-b;
cout<<”Difference : “<>a>>b;
r=a*b;
cout<<”Product : “<>a>>b;
r=a/b;
cout<<”Quotient : “< break;
default:
cout<<”Invalid choice “;
}
getch();
}

0 comments:

Post a Comment

Followers