Hey guys my teacher gave us comments in this program as to what to do in the program. I was pretty sure i filled out everything but low and behold when I try to run the program it doesnt work for some reason. Here is the code I have.
Code:
/* put your #define statements here */
#include <stdio.h>
/* put your prototypes here */
void song(void);
void show(void);
int menu(void);
int main(void)
{
/* declare your variable(s) here */
char choice;
choice = menu(); /* get user's first selection */
while(choice != QUIT)
{
switch(choice)
{
case SHOW: show();
break;
case SONG: song();
break;
default: printf("Oops! An invalid choice slipped through. ");
printf("Please try again.\n");
}
choice = menu(); /* get user's subsequent selections */
}
printf("Bye bye!\n");
/* These next 3 lines are helpful if your program doesn't pause to let you
see the output. (Not required.)
*/
printf("Press Enter to end the program.\n");
fflush(stdin);
getchar();
return 0;
}
int menu(void)
{
int option;
/* Write printf() statements to make the following menu appear on the screen:
Learn more about me! Please select from the menu.
1. Learn the name of my favourite show.
2. Learn the first line of my favourite song.
0. Quit this program.
Please enter your choice:
*/
printf("1. Learn the name of my favourite show.\n");
printf("2. Learn the first line of my favourite song.\n");
while( (scanf(" %d", &option) != 1) /* non-numeric input */
|| (option < 0) /* number too small */
|| (option > 2)) /* number too large */
{
fflush(stdin); /* clear bad data from buffer */
printf("That selection isn't valid. Please try again.\n");
printf("Your choice? ");
}
return option;
}
void song(void)
{
/* Write a printf() statement that will display
the first line of your favourite song.
*/
}
void show(void)
{
/* Write a printf() statement that will display
the title of your favourite TV (or stage) show.
*/