Hey, I have a C programming course and I am currently working on a problem that asks for:
Write a complete C program that will ask the user for a series of temperatures for a city. The value -99 will signify the end of entries. Have the program display the hottest temperature and also the coldest.
I have this as my code and whenever I try it on C it just results in asking me for 2 temperatures then ends. Please help!!
CODE:
insert
Code:
#include<stdio.h>
int
main(void)
{
int temp, hottest, coldest;
printf("Enter a temperature: ");
scanf("%d", temp);
temp = hottest;
temp = coldest;
while(temp != -99)
{
printf("Enter another temperature: ");
scanf("%d", temp);
if(temp>hottest)
{
temp = hottest;
printf("The hottest temperature is %d", hottest);
}
else
{
printf("The hottest temperature is %d", hottest);
}
if(temp<coldest)
{
temp = coldest;
printf("The hottest temperature is %d", coldest);
}
else
{
printf("The hottest temperature is %d", hottest);
}
}
return(0);
}