Skip to content
Solved Examples · Example 18

Q.Write a C program to accept the temperature in Fahrenheit and covert it into Celsius. (Formula : C = (f-32.0)/1.8) The textbook presents this worked program, transcribed exactly as printed (including its printed errors):
#include<stdio.h>  
void main()  
{  
float ct, ft;  
printf("Enter the temperature in Fahrenheit\n");  
scanf("%f", &ft);  
ct=(ft-32.0)/1.8;  
printf("Fahrenheit temperature=%6.2f\n", ft)  
printf("Celsius temperature=%6.2f\n", ct)  
}  
Sample output printed in the textbook:
Enter the temperature in Fahrenheit  
218.80  
Fahrenheit temperature = 218.80  
Celsius temperature = 103.78  

Karnataka PUCTextbookLongImportance★★★★★est
57% · 88/154 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

[!TLDR]

Convert Fahrenheit to Celsius with C = (F - 32.0)/1.8; 218.80 F gives 103.78 C.

The conversion needs real (fractional) arithmetic, so ft and ct are float and the constants 32.0 and 1.8 are written with decimal points to keep the whole expression floating point. The %6.2f edit descriptor controls how the answer is displayed: 6 is the minimum total field width and .2 fixes two digits after the decimal point, giving a neatly aligned 103.78. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.