본문 바로가기

C언어

[C언어] 섭씨 온도를 받아서 화씨 온도 반환

#include <stdio.h>
int temp(int c);  // temp()함수 선언 (함수 원형) 
 
main() 
{
    int c;
    printf("섭씨온도: ");
    scanf("%d"&c);
    printf("화씨온도: %d", temp(c)); 
}
// 사용자 정의 함수 
int temp(int c)
{
    int f;  // 지역변수 선언 
    f = (c * 9 / 5+ 32;  // 섭씨온도 -> 화씨온도 
    return f;  // f값을 반환하여 main()함수의 화씨온도 
}
cs