Pages

Showing posts with label arithmetic. Show all posts
Showing posts with label arithmetic. Show all posts

Thursday, February 12, 2015

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();
}
Read more »