Home > Back-end >  Pray god to help
Pray god to help

Time:11-26

Subject to code program, calculate the corresponding Celsius Fahrenheit 150 F, calculation formula: C=5 x (F? 32)/9, type: C Celsius, F Fahrenheit temperature, output data required for integer,
# include
Int main ()
{
Int C;
Int F=150;
C=5 * (F - 32)/9;
Printf (" fahr=150, Celsius=% d ", C);
return 0;
}
Why display format error?

CodePudding user response:

Results cast a try (int) 5 * (F - 32)/9

CodePudding user response:

Code is no problem, also need not casts, because 5 * (F - 32)/9; Itself is integer arithmetic of data,

The original poster to display what to say about the format? It is wrong to think,

 printf (" fahr=150, Celsius=% d \ n ", C); 

You can add a line break,

CodePudding user response:

Code that's right, should have the error message sent to estimate fault is on the part of the compiler

CodePudding user response:

Code seems to be no problem, what wrong cut a figure

CodePudding user response:

Vs: no problem, the default conversion of the estimate is wrong,

CodePudding user response:




It's nice
  • Related