Do you want to make a simple calculator in programming c. If yes then you are at the right place. In this article i will be publishing a simple code in programming c to make a simple calculator. This calculator will only do some simple tasks like plus, minus, multiply and divide. So, lets get started.
CODE FOR CALCULATOR
#include<stdio.h>
#include<conio.h>
void main(){
int a,b;
char c='+';
printf("enter two no.'s with operator like a-b ");
scanf("%d%c%d",&a,&c,&b);
switch(c){
case '+':
printf("%d + %d = %d\n",a,b,a+b);
break;
case '-':
printf("%d - %d = %d\n",a,b,a-b);
break;
case '*':
printf("%d x %d = %d\n",a,b,a*b);
break;
case '/':
printf("%d / %d = %d\n",a,b,a/b);
break;
default:
printf("entered operator is wrong");
break;
}
getch();
}
0 Comments