화씨를 섭씨로 변환하려고하면 C로 표시된 내 온도 변환 프로그램이 계속 출력됩니다. 섭씨에서 화씨로의 변환은 잘 작동하는 것 같습니다. 두 함수와 부분 모두 똑같은 일을했지만 두 번째 변환에서는 0을 계속 유지합니다. 누군가 나를 도우 려는가 또는 내가 뭘 잘못하고 있는지 말해 줄 수 있습니까? 당신이C 섭씨로 화씨로 0을 출력하는 온도 변환 프로그램
scanf("%f", &*Celsius);
&*
가 사용하고 여기에
#include <stdio.h>
//Function Declarations
float get_Celsius (float* Celsius); //Gets the Celsius value to be converted.
void to_Fahrenheit (float cel); //Converts the Celsius value to Fahrenheit and prints the new value.
float get_Fahrenheit (float* Fahrenheit); //Gets the Fahrenheit value to be converted.
void to_Celsius (float fah); //Converts the Fahrenheit value to Celsius and prints the new value.
int main (void)
{
//Local Declarations
float Fahrenheit;
float Celsius;
float a;
float b;
//Statements
printf("Please enter a temperature value in Celsius to be converted to Fahrenheit:\n");
a = get_Celsius(&Celsius);
to_Fahrenheit(a);
printf("Please enter a temperature value in Fahrenheit to be converted to Celsius:\n");
b = get_Fahrenheit(&Fahrenheit);
to_Celsius(b);
return 0;
} //main
float get_Celsius (float* Celsius)
{
//Statements
scanf("%f", &*Celsius);
return *Celsius;
}
void to_Fahrenheit (float cel)
{
//Local Declarations
float fah;
//Statements
fah = ((cel*9)/5) + 32;
printf("The temperature in Fahrenheit is: %f\n", fah);
return;
}
float get_Fahrenheit (float* Fahrenheit)
{
//Statements
scanf("%f", &*Fahrenheit);
return *Fahrenheit;
}
void to_Celsius (float fah)
{
//Local Declarations
float cel;
//Statements
cel = (fah-32) * (5/9);
printf("The temperature in Celsius is: %f\n", cel);
return;
}
에
변경은 오 와우 난 꽤 많은 광산과 동일 질문을 보지 못했다. 나는이 웹 사이트에 처음 온 복제본에 대해 사과드립니다. – user3377510
적어도 다음에 알 수 있습니다. 그러나 일반적으로이 규칙과 같은 대부분의 초급 유형 문제는 최소한 한 번 (이 경우에는 여러 번) 요청되었으며 게시하기 전에 가능한 많은 관련 질문을 표시해야합니다. –