C PROGRAM TO CONVERT TEMPERATURE (CELSIUS TO FAHRENHEIT)
In this post, we will see a C program to convert temperature from Celsius(°C) to Fahrenheit(°F)
The program accepts the temperature value in °C from user and convert its value equivalent to °F and display the result on the screen.
Step 1: Start
Step 2: Read the temperature value in Celcuis
Step 3: Applying Formula of Conversion i.e, F=(9*C)/5+32
Step 4: Print the Temperature in Fahrenheit
Step 5: Stop
Flow Chart of this Program:
printf("*** www.programmingposts.com ***");
printf("<<< Program for temperature conversion >>>\n\n");
printf("Enter the temperature in Celsius:");
printf("Equivalent Temperature in Fahrenheit: %f",far);
Sample output text:
*** www.programmingposts.com ***
>>> Program for temperature conversion <<<
Enter the temperature in Celsius:38
Equivalent Temperature in Fahrenheit: 100.400002
Explanation for the above program :
1) The #include<stdio.h> includes/loads the file stdio.h into your program while execution. so program can access the in-built functions such as printf(), scanf() etc.
2) main() is the main function where the program execution starts. int is the default return type of main function.
3) The float is a keyword used to declare a variable of fractional type value. i.e. cel,far are variables of type float which represents temperature values.
4) Printf() is a function that prints the text on output screen. And \n is a New Line escape sequence character used to print new line in output.
5) scanf() is a function used to accept input from keyboard.
scanf(“%f”,&cel); reads for the input from the keyboard and store the value in cel which is the temperature value in celsius.
6) far=(9*cel)/5+32; is the conversion formula to get temperature in fahrenheit and this is stored in the variable far.
7) return(0); tells the OS that the program ended successfully.