0

So I'm trying to make like a calculator in C for beginners and I want it to be formatted by asking the first number, the operator, and the second number respectively. However, it only works by asking the numbers first and then the operators, or conversely the operator first and the numbers.

  void main() {
  double a, b;
  char c;
  scanf("%lf", &a);
  scanf("%c", &c);
  scanf("%lf", &b);

So a format something like this would not work. What's the problem?

  • `scanf("%c", &c);` -> `scanf(" %c", &c);`. That is, add space before `%c`. See duplicate post for more details. – kaylum Jun 04 '22 at 04:42

0 Answers0