Q-10.Write a C program to input temperature in Centigrade and convert to Fahrenheit. How to convert temperature from degree centigrade to degree Fahrenheit in C programming. Logic to convert temperature from Celsius to Fahrenheit in C.

1 minute read
0
Write a C program to input temperature in Fahrenheit and convert to Centigrade . How to convert
temperature from degree centigrade to degree Fahrenheit in C programming. Logic to convert
temperature from Celsius to Fahrenheit in C.


  1. #include<stdio.h>


  2. void main()
  3. {
  4.     float celsius,fahrenheit;

  5.     // Reads temperature in fahrenheit
  6.     printf("\nEnter temperature in Fahrenheit:");
  7.     scanf("%f",&fahrenheit);

  8.     // Fahrenheit to celsius conversion formula
  9.     celsius=(fahrenheit - 32)*5/9;
  10.     // Print the result
  11.     printf("\nCelsius = %.3f",celsius);
  12.      //.3f means correct to 3 decimal places
  13.      return 0;
  14. }

     



Write a C program to input temperature in Centigrade and convert to Fahrenheit. How to convert temperature from degree centigrade to degree Fahrenheit in C programming. Logic to convert temperature from Celsius to Fahrenheit in C.



  1. #include<stdio.h>
  2. int main()
  3. {
  4.    float c,F;
  5.     printf("Enter temperature in Centigrade:\n");
  6.     scanf("%f",&c);
  7.     F =(c* 1.8) +32;
  8.     printf("Fahrenheit: = %.2f",F);
  9.      return 0;
  10. }


                                                                           OUTPUT




Post a Comment

0Comments
Post a Comment (0)