Simple calculator
Simple calculator
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int iChoice, iOperand1, iOperand2;
char cOperator;
for(;;)
{
printf("\nEnter the arithmetic expression(Do not add spaces in the
expression)\n");
scanf("%d%c%d", &iOperand1, &cOperator, &iOperand2);
switch(cOperator)
{
case ’+’: printf("\nResult = %d", iOperand1 + iOperand2);
break;
/Output
=================================
***************************************
Enter the arithmetic expression
4+6
Result = 10
Press 1 to continue and 0 to quit : 1
Result = -7
Press 1 to continue and 0 to quit : 1
Result = 10
Press 1 to continue and 0 to quit : 1
Result = 0.8
Press 1 to continue and 0 to quit : 1
Result = 2
Result = 3
Press 1 to continue and 0 to quit : 0
***************************************/