Write a C program to convert the given temperature from Centigrade to Fahrenheit

The formula to convert Centigrade to Fahrenheit is - F = 1.8 * C + 32

void main() 
{ 
 float c, f ; 
 clrscr() ; 
 printf("Enter the centigrade : ") ; 
 scanf("%f", &c) ; 
 f = (1.8 * c + 32) ; 
 printf("\nThe farenheit is : %.2f", f) ; 
 getch() ; 
} 
Output:
Enter the centigrade : 50
The farenheit is : 122.00 
The formula for Fahrenheit to Centigrade conversion is - C = (F - 32) / 1.8
void main() 
{ 
 float c, f ; 
 clrscr() ; 
 printf("Enter the fahrenheit : ") ; 
 scanf("%f", &f) ; 
 c = (f - 32) / 1.8 ; 
 printf("\nThe centigrade is : %.2f", c) ; 
 getch() ; 
} 
Output:
Enter the fahrenheit : 122
The centigrade is : 50.00 

No comments:

Post a Comment