티스토리 뷰

섭씨온도를 화씨온도로 바꾸기 위해서는 아래와 같은 식을 이용합니다.

섭씨온도 = 5.0 / 9.0 x (화씨온도 - 32.0)

 

소스코드는 아래와 같습니다.

#include <stdio.h>

int main(void)
{
int temp;
double result;

printf("화씨 온도를 입력해주세요 : ");
scanf("%d", &temp);

result = 5.0/9.0 * ((double)temp-32.0);

 printf("변환된 섭씨 온도는 %.4lf입니다.", result);

return 0;
}

 

코드의 테스트를 위해서 아래의 링크에 방문해서 테스트 합니다.

https://www.onlinegdb.com/online_c_compiler

 

Online C Compiler - online editor

OnlineGDB is online IDE with c compiler. Quick and easy way to compile c program online. It supports gcc compiler for c.

www.onlinegdb.com

 

화씨온도를 섭씨온도로 바꾼 화면

 

 

댓글