Friday, 2 March 2018

C Program: Make a Calculator by using switch Statement

Here we will discuss about how to make calculator by switch statment in C.Switch is conditioanl statement.


Make a Calculator by using switch Statement

C Program: Make a Calculator by using switch Statement

#include<stdio.h>
#include<conio.h>
#inculde<math.h>
void main()
{
int a,b,c;
char op;
clrscr();
printf("Enter 1st Number :");
scanf("%d",&a);
printf("Enter Operator:\n");
scanf("%c",&op);
printf("Enter 2nd Number:");
scanf("%d",&b);
switch (op)
{
case '+':
c=a+b;
printf("Addition=%d",c);
break;
case '-':
c=a-b;
printf("Subtraction=%d",c);
break;
case '*':
c=a*b;
printf("Multiplication=%d",c);
break;
case '/':
c=a/b;
printf("Devision=%d",c);
break;
case '%':
c=a%b;
printf("Reminder=%d",c);
break;
default:printf("Wrong Input");
}
getch();
}
Share This
Previous Post
Next Post

Admin and author of BestBCANotes. Complted master degree in Computer Science.

0 comments: