I have an assignment for a very basic C course. SOmebody please help me I am veyr new at this.
Bruce
THe question is:
You have taken a job at a year-round resort where the owner has just
installed a computerized sign. You are to program the sign to show
the current temperature and a recommended activity.
Your program should read the temperature from the keyboard and
print out the activity appropriate for that temperature using the
following guidelines:
Activity Temperature
---------------------------------------- ------
Swimming 30 < temperature
Tennis 20 < temperature <= 30
Golf 0 < temperature <= 20
Skiing -17 < temperature <= 0
Dancing temperature <= -17
---------------------------------------- ------
*/
#include
Bruce
THe question is:
You have taken a job at a year-round resort where the owner has just
installed a computerized sign. You are to program the sign to show
the current temperature and a recommended activity.
Your program should read the temperature from the keyboard and
print out the activity appropriate for that temperature using the
following guidelines:
Activity Temperature
----------------------------------------
Swimming 30 < temperature
Tennis 20 < temperature <= 30
Golf 0 < temperature <= 20
Skiing -17 < temperature <= 0
Dancing temperature <= -17
----------------------------------------
*/
#include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]
I have an assignment for a very basic C course. SOmebody please help me I am veyr new at this.
Bruce
<lj-cut text = "problem">
THe question is:
You have taken a job at a year-round resort where the owner has just
installed a computerized sign. You are to program the sign to show
the current temperature and a recommended activity.
Your program should read the temperature from the keyboard and
print out the activity appropriate for that temperature using the
following guidelines:
Activity Temperature
----------------------------------------------
Swimming 30 < temperature
Tennis 20 < temperature <= 30
Golf 0 < temperature <= 20
Skiing -17 < temperature <= 0
Dancing temperature <= -17
----------------------------------------------
*/
#include <stdio.h>
int main(void)
{
FILE* out = fopen("activity.out", "a");
So far I have this:
#include <stdio.h>
int main(void)
{
FILE* out = fopen("activity.out", "a");
float temp ;
printf("Enter the temperature in degrees celcius:\t");
fprintf(out, "What is the tempurature in degrees celcius?\n");
scanf("%f" , &temp ) ;
if(temp > 30)
fprintf(out, "You should go swimming.");
Else if(temp > 20)
fprintf(out, "You should play tennis.");
Else if(temp > 0)
fprintf(out, "You should go golfing.");
Else if(temp > -17)
fprintf(out, "You should go skiing.");
Else if(temp <= 17)
fprintf(out, "You should go dancing.");
return 0;
}
Apparently I am missing " ; " before " if". Also it tells me "else" is undeclared identifier.
</lj-cut>
Bruce
<lj-cut text = "problem">
THe question is:
You have taken a job at a year-round resort where the owner has just
installed a computerized sign. You are to program the sign to show
the current temperature and a recommended activity.
Your program should read the temperature from the keyboard and
print out the activity appropriate for that temperature using the
following guidelines:
Activity Temperature
----------------------------------------------
Swimming 30 < temperature
Tennis 20 < temperature <= 30
Golf 0 < temperature <= 20
Skiing -17 < temperature <= 0
Dancing temperature <= -17
----------------------------------------------
*/
#include <stdio.h>
int main(void)
{
FILE* out = fopen("activity.out", "a");
So far I have this:
#include <stdio.h>
int main(void)
{
FILE* out = fopen("activity.out", "a");
float temp ;
printf("Enter the temperature in degrees celcius:\t");
fprintf(out, "What is the tempurature in degrees celcius?\n");
scanf("%f" , &temp ) ;
if(temp > 30)
fprintf(out, "You should go swimming.");
Else if(temp > 20)
fprintf(out, "You should play tennis.");
Else if(temp > 0)
fprintf(out, "You should go golfing.");
Else if(temp > -17)
fprintf(out, "You should go skiing.");
Else if(temp <= 17)
fprintf(out, "You should go dancing.");
return 0;
}
Apparently I am missing " ; " before " if". Also it tells me "else" is undeclared identifier.
</lj-cut>
