Pages

Monday, October 10, 2011

3.Programming in C++ with output


WAP TO ENTER 2 NUMBERS AND ADD,SUB,MULT OR DIVIDE THEM AS PER USER CHOICE
ALSO USER HAS TO ENTER THE DESIRE CHARACTER REPRESENTING THE CALCULATION
for e.g, see the output


#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
char op;
float a,b,c;
cout<<"Enter 2 numbers::";
cin>>a>>b;
cout<<"Enter + to add"<<endl
    <<"- to subtract"<<endl
    <<"* to multiply"<<endl
    <<"/ to divide::";
cin>>op;
switch(op)
{
case '+':
c=a+b;
break;

case '-':
c=a-b;
break;

case '*':
c=a*b;
break;

case '/':
c=a/b;
break;
}
cout<<"Result::"<<c;
getch();
}

No comments: