Home > Back-end >  Beginner C language of the small white, every brother for help
Beginner C language of the small white, every brother for help

Time:02-10

# include
Void Temperature (float t);
Int main (void)
{
Float t, s, k;

Printf (" please enter the Fahrenheit (decimal zero not omit) : ");
The scanf (" % f ", & amp; T);
While (the scanf (" % f ", & amp; T)==1)
{
Temperature (t);
Printf (" Fahrenheit temperature: % 2 f \ n degrees Celsius temperature: %, 2 f \ n kelvin temperature: %, 2 f ", t, s, k);
}
Printf (" end ");

return 0;
}
Void Temperature (float t)
{
Float s, k;

S=5.0/9.0 * (t - 32.0);
K=s + 273.16;
}



After running, input t values, the desired print things did not print it out, but continue to let me enter, if I enter the Numbers, he will immediately show the end, if is a function of t value is not to create the
Why


CodePudding user response:

 # include 
Void Temperature (float t, float * s, float * k);
Int main (void)
{
Float t, s, k;

Printf (" please enter the Fahrenheit (decimal zero not omit) : ");
//the scanf (" % f ", & amp; T);//remove the input, or need to enter twice ~
While (the scanf (" % f ", & amp; T)==1)//there is also a the scanf, use a, it is suggested that keep this ~
{
Temperature (t, & amp; S, & amp; k);
Printf (" Fahrenheit temperature: % 2 f \ n degrees Celsius temperature: %, 2 f \ n kelvin temperature: %, 2 f ", t, s, k);
}
Printf (" end ");

return 0;
}
Void Temperature (float t, float * s, float * k)
{
//float s, k;

* * s=5.0/9.0 (t - 32.0);
* * s + k=273.16;
}

For your reference ~

CodePudding user response:

While (the scanf (" % f ", & amp; T)==1), what do you think the while () is only a judgment, just like usual judgment if function==0 (XXX) return - 1; XXX function still perform
  • Related