:-Write a program in C++ for Simulation of a Simple Calculator using Switch Case.
#include<iostream.h>
void main()
{
int a,b,o;
float c;
cout<<"\n enter the two operands: ";
cin>>a>>b;
cout<<"\n enter 1 for addition";
cout<<"\n enter 2 for subtruction";
cout<<"\n enter 3 for multiplication";
cout<<"\n enter 4 for division";
cin>>o;
switch(o)
{
case 1: c=a+b;
cout<<c;
break;
case 2: c=a-b;
cout<<c;
break;
case 3: c=a*b;
cout<<c;
break;
case 4: c=a/b;
cout<<c;
break;
default : cout<<"wrong choice";
}
}
The Output of this Program :-
#include<iostream.h>
void main()
{
int a,b,o;
float c;
cout<<"\n enter the two operands: ";
cin>>a>>b;
cout<<"\n enter 1 for addition";
cout<<"\n enter 2 for subtruction";
cout<<"\n enter 3 for multiplication";
cout<<"\n enter 4 for division";
cin>>o;
switch(o)
{
case 1: c=a+b;
cout<<c;
break;
case 2: c=a-b;
cout<<c;
break;
case 3: c=a*b;
cout<<c;
break;
case 4: c=a/b;
cout<<c;
break;
default : cout<<"wrong choice";
}
}
The Output of this Program :-
I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog. 140 lbs to kg
ReplyDeleteThanks and cheers
ReplyDelete