Hello,
My father and I are learning C with the intention of eventually learning C++.
This program worked fine until I tried to add a "Continue or Quit" option. I've spent at least 6 hours trying to make it work.
Will someone please tell me what I need to do in order to make it work.
Been learning C for only about 3 weeks.
Thank you
Code:#include <stdio.h> int best_team(void); int main(void) { int team; int again = 0; team = best_team(); printf("\nYour favorite team on this list is the %s\n\n",team); /*THIS IS THE PART THAT IS NOT WORKING /*printf("Would you like to choose another team?\n\n"); printf("Enter 1 to choose another team or 0 to quit.\n\n"); scanf("%d", again); if(again == 1); { return main(); } */ system("PAUSE"); return 0; } int best_team(void) { int choice = 0; do { printf("\n"); printf("\nWho is your favorite team on this list?\n"); printf("\n1 - Seattle Seahawks?"); printf("\n2 - San Francisco 49'ers?"); printf("\n3 - Arizona Cardinals?"); printf("\n4 - St. Louis Rams?"); printf("\n"); printf("\nPlease make your selection and press ENTER\n\n"); scanf("%d", &choice); if(choice < 1 || choice > 4) printf("\nIm sorry, that selection is not valid; you must choose 1,2,3 or 4.\n"); if(choice < 1 || choice > 4) printf("\nPlease make a valid selection\n\n"); } while( choice < 1 || choice > 4 ); if(choice == 1) return "Seattle Seahawks.\nEXCELLENT CHOICE.\nThey are the best team in the land."; if(choice == 2) return "San Francisco 49'ers.\nThey are a fine team...\nbut not as good as our Seahawks."; if(choice == 3) return "Arizona Cardinals.\nA decent team over-all...\nbut not the best team in the land."; if(choice == 4) return "St. Louis Rams.\nPerhaps you should choose again..."; }



1Likes
LinkBack URL
About LinkBacks





