C Arithmetic Calculator
While doing some mathematical problems, calculator plays a major role. We the programmer, are not supposed to use physical calculator, we just create it by our own coding. Here is a C program to perform arithmetic operations for solving your mathematical problems.
C Program - Arithmetic Calculator
It's time to write a c program to perform arithmetic operations.
C Program to Create Simple Calculator
#include<stdio.h>
int main()
{
int n,a,b;
printf("1 for addition\n");
printf("2 for subtraction\n");
printf("3 for multiplication\n");
printf("4 for division\n");
printf("please enter 1-4 digit\n");
scanf("%d",&n);
printf("Please enter two numbers:");
scanf("%d %d",&a,&b);
switch(n)
{
case 1:
printf("%d",a+b);
break;
case 2:
printf("%d",a-b);
break;
case 3:
printf("%d",a*b);
break;
case 4:
printf("%d",a/b);
break;
default:
printf("you enter wrong key\n");
}
}

0 Comments