City Suvidha...your one stop Search

C Programs

Go Back to List

Program to display arithmetic operator using switch case.

 


#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,n,s,m,su,d;
clrscr();
printf("enter two no's : ");
scanf("%d%d",&a,&b);
printf("enter 1 for sum\n2 for multiply\n3for subtraction\n4 for division: ");
scanf("%d",&n);
switch(n)
{
case 1:
s=a+b;
printf("sum=%d",s);
break;
case 2:
m=a*b;
printf("multiply=%d",m);
break;
case 3:
su=a-b;
printf("subtraction=%d",su);
break;
case 4:
d=a/b;
printf("divission=%d",d);
break;
default:
printf("wrong input");
break;
}
getch();
}


 

 

Output:


enter two no’s: 8
4
enter 1 for sum
2 for multiply
3 for subtraction
4 for division: 1
sum=12



 

If any of you want to submit your programs and contribute to site please mail us at:

citysuvidha@gmail.com

  Click here to have a look at  List of programs

You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum  and start any thread of any topic.  Once you start the thread and put your request, admin will automatically send you the desired zip file.