Featured
- Get link
- X
- Other Apps
Simple calculator in C
Hello, I've made simple calculator using C language and It can perform basic commands of calculator like Addition, Subtraction etc on 2 numbers.
Here is its code:-)
#include<stdio.h>
#include<stdlib.h>
int main()
{
int num1,num2;
char ch;
float r,p;
printf("This is calculator\n");
printf("for sum type + sign\n");
printf("for substracation type - sign\n");
printf("for multipllication type * sign\n");
printf("for devision type / sign\n");
scanf("%c",&ch);
printf("enter two numbers");
scanf("%d%d",&num1,&num2);
switch(ch)
{
case '+':
printf("sum is %d",num1+num2);
break;
case '-':
printf("sub. is %d",num1-num2);
break;
case '*':
printf("multi. is %d",num1*num2);
break;
case '/':
r = num1/num2;
printf("devision is %f",r);
break;
default:
printf("invalid input");
}
return 0;
}