Saturday, 6 July 2019

How to make a calculator in C language

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..

2 comments:

Featured post

 Top 10 Array Coding Question For Interview: (1)Write a program to find smaller element in Array Solution:      public class SmallerElementI...