andom Wite a program that generates a random temperature of water in degrees Cel
ID: 3307825 • Letter: A
Question
andom Wite a program that generates a random temperature of water in degrees Celsius and converts that value to Fahrenheit. The range of values for the temperature should be between o and 100 degrees Celsius The formula for conversion from Celsius to Fahrenheit is Fahrenheit-Celsius + 32 Your program should include: A random object to generate an integer between 0 and 100 e Note: no input, or hardcoded number is needed Varlables to store the random umber as well as the calculated Fahrenhelt value Tip: watch out for integer division Samples of the output are shown below Sample 1 This program generates a random temperature in Celsius and converts it to Fahrenheit The temperature selected is: 42 42 Celsius is 107.60000000000001 Fahrenheit Sample 2: This program generates a random temperature in Celsius and converts it to Fahrenheit The temperature selected is: 98 98 Celsius is 208.4 FahrenheitExplanation / Answer
Solution ; -
#include<isostream.h>
#include<conio.h>
void main()
{
int c=100,f;
for(c=100;c>=0;c--)
{
f=32+(9/5)*c;
if(c==f)
{
cout<<c<<endl;
break;
}
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.