इस प्रोग्राम में हम सीखेंगे कि किस प्रकार C प्रोग्रामिंग में switch स्टेटमेंट के साथ अरिथ्मेटिक ऑपरेटर का प्रयोग किया जाता है |
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,result;
clrscr();
printf("enter two no’s : ");
scanf("%d%d",&a,&b);
printf("enter 1 for sum\n2 for multiply\n3 for subtraction\n4 for division: ");
scanf("%d",&n);
switch(n)
{
case 1:
result=a+b;
printf("sum=%d",result);
break;
case 2:
result=a*b;
printf("multiply=%d",result);
break;
case 3:
result=a-b;
printf("subtraction=%d",result);
break;
case 4:
result=a/b;
printf("divission=%d",result);
break;
default:
printf("wrong input");
break;
}
getch();
}
Output:
enter two no’s: 5
6
enter 1 for sum
2 for multiply
3 for subtraction
4 for division: 2
multiply=30






