Simple Calculator program in C
Here, you will get a simple calculator program in c programming language. This program will perform basic mathematical operations like addition, subtraction, multiplication, and division of two numbers.
Algorithm
Step 1 : Input any two numbers.
Step 2 : Calculate the sum of two numbers.
Step 3 : Calculate the difference of two numbers.
Step 4 : Calculate the product of two numbers.
Step 5 : Calculate the quotient of two numbers.
Step 6 : Print the sum, difference, product, quotient.
Data Flow Diagram(DFD)
Example Code of Calculator Program in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //program to perform all Basic Arithmetic Operations. #include<stdio.h> #include<conio.h> void main( ) { int a,b; float c,d,e,f; printf(“\nEnter two values :”); scanf(“%d%d”,&a,&b); c=a+b; d=a-b; e=a*b; f=(float)a/b; printf(“Addition=%f\nSubstraction=%f\nMultiplication=%f\nDivision=%f”,c,d,e,f); getch(); } |
Input:
Enter two values: 7 4
Output:
Addition=11
Subtraction=3
Multiplication=28
Division=1.400000
Check out our other C programming Examples