Home > Back-end >  C language design calculator
C language design calculator

Time:12-08

How can write a calculator in c, at the same time operation integer and floating point? Operation/and %, it will only input integer operations, will not enter a floating point,

CodePudding user response:

Float
The scanf (" % f
Or
Double
The scanf (" % lf

CodePudding user response:

This I know, but if you can't write float operation %, I want to know how to input integer and floating point type, for example, for the first time is 4 + 1, the second 4.5 + 1,

CodePudding user response:

Before you enter/and % already enter the Numbers? How to limit? Automatic conversion can only according to/and %, float not plastic, otherwise can only choose plastic and floating point button before use,

CodePudding user response:

The scanf (" % d % d % c ", & amp; A, & amp; D, & amp; B);
The switch (d)
{
}
Printf (" % d % c % d=%. The 2 f \ n ", a, d, b, c);
I use the switch control operator, but it can only input integer arithmetic, I can't to enter a floating point and operation %, how can merging the two at the same time

CodePudding user response:

You this is to develop new type of calculator? Calculator which have take over operations, the percentage if you don't have to take more than agreed that their bai, input all use floating point, and then if it is # % to the floating point will be converted to an integer, not acquired at the same time
  • Related