X
X
xDany2019-04-04 16:49:47
C++ / C#
xDany, 2019-04-04 16:49:47

Problem in the code, what to add / fix?

I am newbie. I'm just learning C language, and then I wrote a small program. The problem is that everything works, the result is displayed without errors, BUT, before the result appears in the terminal, I must write at least something (for example, "a") in order for the program to work to the end. What is the error, what to add / correct so that without additional. Did you complete the input code? Thank you in advance)))

#include <stdio.h>

int main()
{
  float fahr, celsius;
  printf("Введите значение: ");
  scanf("%f\n", &fahr);
  celsius = 5 * (fahr - 32) / 9;
  printf("Фаренгейт\tЦельсий\n");
  printf("%0.0f\t%13.1f\n", fahr, celsius);
  return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ronald McDonald, 2019-04-04
@xDany

Try this instead:
scanf("%f", &fahr);

L
Lander, 2019-04-04
@usdglander

Of course, I'm not an expert, but perhaps scanfyou are expecting exactly float. So try typing 5.3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question