C Programming Code Examples C > Mathematics Code Examples C Program to Simulate a Simple Calculator C Program to Simulate a Simple Calculator This C Program simulates a simple calculator. This program performs arithmatic operations like addtion, subraction, multiplication & division. Assume that the 2 numbers a & b are given. For the given element we need to perform addition, subtraction, multiplication & division. #include <stdio.h> void main() { char operator; float j1, j2, result; printf("Simulation of a Simple Calculator\n"); printf("*********************\n"); printf("Enter two numbers \n"); scanf("%f %f", &j1, &j2); fflush(stdin); printf("Enter the operator [+,-,*,/] \n"); scanf("%s", &operator); switch(operator) { case '+': result = j1 + j2; break; case '-': result = j1 - j2; break; case '*': result = j1 * j2; break; case '/': result = j1 / j2; break; default : printf("Error in operationn"); break; } printf("\n %5.2f %c %5.2f = %5.2f\n", j1, operator, j2, result); }