Home > Back-end >  Simple calculator
Simple calculator

Time:12-17

# include & lt; Stdio. H>
# include & lt; Math. H>
Void main ()
{
int a;
Float b, c, the result;
Printf (" * * * * * * simple calculator * * * * * * * * * * * \ n ");
Printf (" 1. Add operation \ n ");
Printf (" 2. Subtract \ n ");
Printf (" 3. The multiplication \ n ");
Printf (" 4. Divide \ n ");
Printf (" 5. Exponentiation computation \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
While (1)
{
Printf (" please enter the operation sequence number: ");
The scanf (" % d ", & amp; a);
The switch (a)
{
Case 1: the scanf (" % f % f ", & amp; B, & amp; C);
Printf (" % f + % % f=f \ n ", b, c, b + c);
break;
Case 2: the scanf (" % f % f ", & amp; B, & amp; C);
Printf (" % f, % f=% f \ n ", b, c, b, c);
break;
Case 3: the scanf (" % f % f ", & amp; B, & amp; C);
Printf (" % f * % % f=f \ n ", b, c, b * c);
break;
Case 4: the scanf (" % f % f ", & amp; B, & amp; C);
Printf (" % % % f/f=f \ n ", b, c, b/c);
break;
Case 5: the scanf (" % f ", & amp; b);
Printf (" % f * % % f=f \ n ", b, b, b * b);
break;
Default:
Printf (" input your data is wrong, please input again!" );
}
}
}

CodePudding user response:

Good,,,

CodePudding user response:

Division note divisor cannot be zero
  • Related