Here’s how you would use a for loop;
#include <stdio.h> #include <string.h> #include <stdbool.h> #include <ctype.h> int main(void) { bool hasDigit; char passCode[50]; hasDigit = false; strcpy(passCode, "abc"); /* Your solution goes here */ for (int i=0; passCode[i]; i++) if (isdigit(passCode[i])) hasDigit = true; if (hasDigit) { printf("Has a digit.\n"); } else { printf("Has no digit.\n"); } return 0; }