Home > Back-end >  C language corrected written procedures but lose out results
C language corrected written procedures but lose out results

Time:09-16

Why I this code output is 0.00


#include
Int main () {
Double F, c;
Printf (" please enter the Fahrenheit temperature F: ");
Lf the scanf (" % ", & amp; F);
C=5/9 * (F - 32);
Printf (" output Celsius temperature c: % 2 f ", c);




}

CodePudding user response:

C=5/9 (double) * (F - 32);

CodePudding user response:

5/9 integer arithmetic results integer 0, convert 5 to double, is the type double operation,

CodePudding user response:

Agree with upstairs, or * c=5.0/9 (F - 32);

CodePudding user response:

5/9=0
You simple procedures to run once, and then think about

CodePudding user response:

Type conversion cannot be too careful in the C ~ ~ ~

 c=5.0/9.0 * (F - 32); 

CodePudding user response:

Totally agree with upstairs in the upstairs

CodePudding user response:

Change the 5 to 5.0, because 5 and 9 is integer, 5/9 quotient is 0, so your output is zero

CodePudding user response:

Change the 5 to 5.0, because 5 and 9 is integer, 5/9 quotient is 0, so your output is zero
  • Related