When you have source code, please make the following frame; #include <stdio.h> #
ID: 3628165 • Letter: W
Question
When you have source code, please make the following frame;
#include <stdio.h>
#include <stdlib.h>
int main (int argo, char* argv[])
{
printf("hello world ! "); // this is an example
system("pause");
return 0 ;
}
It is absolutely crucial to end all of your programs with:
return 0;
as the last line before the closing '}' bracket in your main function.
Programs that do not follow this convention will not be graded correctly.
Programs that end with that line may still fail because they do not generate the right output.
Each sample run is indicated by a line of "=" symbols. These lines only indicate
the start and the end of a sample run and should not be printed by your program.
Problem 2
#########
Write a program that estimates the temperature in a freezer (in degrees Celsius)
given the elapsed time (in hours) since a power failure. Assume that this
temperature (T) is given by:
T = (4 * t * t) / (t + 2) - 20
where t is the time since the power failure. Your program should prompt the user
to enter how long it has been since the start of the power failure in whole
hours and minutes (two integers on one line). Note that you will need to convert
the elapsed time into hours. For example, if the user entered 2 30 (2 hours 30 minutes),
you would need to convert this to 2.5 hours.
Print the answer with two digit precision (i.e., "%.2f" in printf).
You can assume that the number of hours and minutes is always an integer.
The program should interact with the user exactly as shown below,
including printing "Temperature:" (the numbers may be different
depending on the user input!)
Remarks: Use the following code to prompt the user: printf("Enter time: ");
============= START OF SAMPLE RUN =======================
Enter time:
2 30
Temperature:
-14.44
============= END OF SAMPLE RUN =======================
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
int main (int argo, char* argv[])
{
float t,T;
int t1,t2;
printf("============= START OF SAMPLE RUN ======================= ");
printf(" enter Time :");
scanf("%d %d",&t1,&t2);
t = t1+(t2/60.0);
T = (4 * t * t) / (t + 2) - 20;
printf(" Temperature is given by :%.2f",T);
printf(" ============= END OF SAMPLE RUN ======================= ");
system("pause");
return 0 ;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.