Computer >> 컴퓨터 >  >> 프로그램 작성 >> C 프로그래밍

C 프로그램을 사용하여 화씨를 섭씨로 변환

<시간/>

화씨를 섭씨로 변환하기 위해 구현한 논리는 다음과 같습니다. -

celsius = (fahrenheit - 32)*5/9;

알고리즘

화씨를 섭씨로 변환하려면 아래 주어진 알고리즘을 참조하십시오.

Step 1: Declare two variables farh, cels
Step 2: Enter Fahrenheit value at run time
Step 3: Apply formula to convert
        Cels=(farh-32)*5/9;
Step 4: Print cels

예시

다음은 화씨를 섭씨로 변환하는 C 프로그램입니다 -

#include<stdio.h>
int main(){
   float fahrenheit, celsius;
   //get the limit of fibonacci series
   printf("Enter Fahrenheit: \n");
   scanf("%f",&fahrenheit);
   celsius = (fahrenheit - 32)*5/9;
   printf("Celsius: %f \n", celsius);
   return 0;
}

출력

위의 프로그램을 실행하면 다음과 같은 결과가 나온다 -

Enter Fahrenheit:

100
Celsius: 37.777779