C Program to do arithmetic operations according to user choice using switch case
include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int a,b;
char c;
cout<<"Enter any expression(ex:3*7):";
cin>>a>>c>>b;
switch(c)
{
case+: cout<<"
Result:"<<a+b;
break;
case-: cout<<"
Result:"<<a-b;
break;
case*: cout<<"
Result:"<<a*b;
break;
case/: cout<<"
Result:"<<a/b;
break;
case%: cout<<"
Result:"<<a%b;
break;
}
getch();
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.