Challenge 2: Build a number guessing game that uses input validation (isdigit function) to verify that the user has entered a digit and not a non-digit (letter).
Unable to get this program to work. I've tried everything.
LoriCode://Chapter 3 Challenge 2 //by Lori Macdonald #include <stdio.h> #include <ctype.h> main() { int iRandomNum = 0; int iResponse = 0; srand(time()); iRandomNum = (rand() % 10) + 1; printf("\nGuess a number between 1 and 10: "); scanf("%d", &iResponse); getch(); switch (iResponse) { case 1: if (isdigit(iResponse)) printf("\nThank you\n"); else { printf("\nYou did not enter a digit\n"); } case 2: if (iResponse == iRandomNum) printf("\nYou guessed right\n"); else { printf("\nSorry, you guessed wrong\n"); printf("The correct guess was %d\n", iRandomNum); }} getch(); }