Breaking News

Switch-Case Example in C

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
char op,choice;
clrscr();
do
{
printf("enter two no");
scanf("%d%d",&a,&b);
printf("enter the operator");
flushall();
scanf("%c",&op);
switch(op)
{
case '+':
c=a+b;
printf("%d",c);
break;
case '-':
c=a-b;
printf("%d",c);
break;
case '*':
c=a*b;
printf("%d",c);
break;
case '/':
c=a/b;
printf("%d",c);
break;
default:
printf("wrong operator");
}
printf("do u want to coninue y/n:");
flushall();
scanf("%c",&choice);
}
while(choice=='y');
getch();
}

No comments