GEEN 2312: Introduction to Computing Assignment 1 Due Date: Wednesday February 1
ID: 3668143 • Letter: G
Question
GEEN 2312: Introduction to Computing
Assignment 1
Due Date:
Wednesday February 17, 2016
Submission Method: Demo/Email
Write a C program that will allow the user to enter a temperature in Fahrenheit and convert it to Celsius according to the following formula where F is the temperature in Fahrenheit and C is the corresponding temperature in Celsius:
C = (F-32)*5/9;
For example, if F=41, then
C=(41 – 32) * 5/9=5
Your program should behave as follows (the underlined is data entered by the user):
Please enter the temperature in Fahrenheit> 41
The corresponding temperature in Celsius is 5.0
To make sure that your program works properly, test again using the data in the following table:
Fahrenheit
Celsius
37.6
3.1
90.5
32.5
120.7
49.3
Please note the following:
In the main function, declare two variables called celsius and fahrenheit to store the temperatures in Celsius and Fahrenheit respectively.
Format the output rounded to 1 decimal place as shown above.
Fahrenheit
Celsius
37.6
3.1
90.5
32.5
120.7
49.3
Explanation / Answer
#include <stdio.h>
int main()
{
float forienheat,celsius;
printf("Please enter the temperature in Fahrenheit>");
scanf("%f",&forienheat);
celsius=(forienheat-32)*5/9;
printf("The corresponding temperature in Celsius is%.1f",celsius);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.