fork download
  1. char RepeatProgramPrompt()
  2. {
  3. char repeatProgram;
  4.  
  5. do
  6. {
  7. printf("\nTo exit enter q, to continue enter y.\n");
  8. scanf("%c", &repeatProgram);
  9. while(getchar() != '\n')
  10. {
  11. }
  12. repeatProgram = tolower(repeatProgram);
  13.  
  14. if(repeatProgram != 'y' && repeatProgram != 'q')
  15. {
  16. printf("\nYou've entered %c, that isn't a valid option.\n", repeatProgram);
  17.  
  18. }
  19.  
  20. }while(repeatProgram != 'y' && repeatProgram != 'q');
  21.  
  22.  
  23. return(repeatProgram);
  24. }
  25. int main()
  26. {
  27. RepeatProgramPrompt();
  28. }
Runtime error #stdin #stdout 0s 2252KB
stdin
a 
b
c
q
stdout
To exit enter q, to continue enter y.

You've entered a, that isn't a valid option.

To exit enter q, to continue enter y.

You've entered b, that isn't a valid option.

To exit enter q, to continue enter y.

You've entered c, that isn't a valid option.

To exit enter q, to continue enter y.