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



Make a Calculator by using switch Statement




C Program to Make a Simple Calculator Using switch case



#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();

}


Post a Comment

Previous Post Next Post