ProgrammingModerate
int count = 0; for (const char *p = "a1b22c"; *p; p++) if (isdigit((unsigned char)*p)) count++; printf("%d", count); What is printed?
- A. 3
- B. 2
- C. 4
- D. 5
Correct answer: A. 3
The digits are 1, 2 and 2, giving three digit characters in total.
More C Programming questions
- char name[8] = "Sam"; printf("%d %d", (int)sizeof name, (int)strlen(name)); What is printed?
- char s[] = "12345"; int v = 0; for (int i = 0; s[i]; i++) v = v 10 + (s[i] - '0'); printf("%d", v); What is printed?
- char s[] = "ab"; char q = s + 2; printf("%d", q); What is printed?
- char c = 'A'; printf("%d %c", c + 1, c + 1); What is printed?
- printf("%s", "abc" + 1); What is printed?
- char name[] = "Bob"; char p = name; printf("%c%c", p[0], (p + 2)); What is printed?