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<<“nResult:”<<a+b;
break;

case’-‘: cout<<“nResult:”<<a-b;
break;

case’*’: cout<<“nResult:”<<a*b;
break;

case’/’: cout<<“nResult:”<<a/b;
break;

case’%’:  cout<<“nResult:”<<a%b;
break;
}

getch();
}

1 thought on “C++ Program to do arithmetic operations according to user choice using switch case”

Leave a Comment

Your email address will not be published. Required fields are marked *