calculator in c using switch case statement
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch,result;
while(1)
{
printf("\n1. addition");
printf("\n2. subtraction");
printf("\n3. multiplication");
printf("\n4. division");
printf("\n5. exit");
printf("\n enter you choice:-");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter two numbers:-");
scanf("%d%d",&a,&b);
result=a+b;
printf("sum is %d",result);
break;
case 2:
printf("enter two numbers:-");
scanf("%d%d",&a,&b);
result=a-b;
printf("subtraction is %d",result);
break;
case 3:
printf("enter two numbers:-");
scanf("%d%d",&a,&b);
result=a*b;
printf("multiplication is %d",result);
break;
case 4:
printf("enter two numbers:-");
scanf("%d%d",&a,&b);
result=a/b;
printf("division is %d",result);
break;
case 5:
exit(0);
default:
printf("invalid entry");
}
}
getch();
}
if you want to learn more programing and programing practice in c language then comment below and follow this blog...thanks to all of you..
Wow nice
ReplyDeleteSuperb work bro.
ReplyDelete