Practical 2
#include<iostream.h>
#include<conio.h>
int main()
{
int a,b;
cout<<"Enter value of a:";
cin>>a;
cout<<"Enter value of b:";
cin>>b;
int c=1;
while(c==1)
{
int choice;
cout<<"1.Add\n2.subtract\n3.mul\n4.div"<<endl;
cin>>choice;
switch(choice)
{
case 1:cout<<"Addition is:"<<a+b<<endl;
break;
case 2:cout<<"Subtraction is:"<<a-b;
break;
case 3:cout<<"multiplication is:"<<a*b;
break;
case 4:cout<<"Division is:"<<a/b;
break;
default:cout<<"Enter proper choice!!!"<<endl;
}
cout<<"Do you want to continue? (0/1):";
cin>>c;
}
return 0;
}
output:
Enter value of a
5
Enter value of b
5
1.Add
2.subtract
3.mul
4.div
1
addition is 10
do you want to continue?
0
No comments:
Post a Comment