//Write a program to design calculator in C
#include<stdio.h>
#include<conio.h>
void main()
{
int ch,n1,n2,r;
printf("1 Addition\n2 Subtraction\n3 Multiplication\n4 Division\n");
printf("Enter your choice");
scanf("%d",&ch);
printf("Enter first value ");
scanf("%d",&n1);
printf("Enter second value ");
scanf("%d",&n2);
switch(ch)
{
case 1:
r=n1+n2;
printf("Addition of first and second value is %d",r);
break;
case 2:
r=n1-n2;
printf("Subtraction of first and second value is %d",r);
break;
case 3:
r=n1*n2;
printf("Multiplication of first and second value is %d",r);
break;
case 4:
r=n1/n2;
printf("Division of first and second value is %d",r);
break;
default:
printf("Out of option");
}
getch();
}
Tags
B.Tech