Friday, October 11, 2013

C++ program to ADD,MULTIPLY,SUBSTRACT,DIVISION of numbers using switch case

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,choice,error;
cout<<endl<<"enter two no.";
cin>>a>>b;
cout<<endl<<"choose the operation which you want to do";
cout<<endl<<"addition";
cout<<endl<<"substration";
cout<<endl<<"multiplication";
cout<<endl<<"division";
cout<<endl<<"enter your choice";
cin>>choice;
switch(choice)
{
case 1:
cout<<endl<<"addition="<<a+b;
break;
case 2:
if(a>b)
cout<<endl<<"substraction="<<a-b;
else
cout<<endl<<"substraction="<<b-a;
break;
case 3:
cout<<endl<<"multiplication="<<a*b;
break;
case 4:
if(b==0)
cout<<endl<<"error"<<error;
else
cout<<endl<<"division="<<a/b;
break;
}
getch();
}

No comments:

Post a Comment