ProgrammingModerate
char cnt[26] = {0}; cnt['c' - 'a']++; printf("%d", (int)('c' - 'a')); What is printed?
- A. 2
- B. 3
- C. 99
- D. 1
Correct answer: A. 2
'c' - 'a' is 2 for ASCII letters, and that index is the one incremented.
More C Programming questions
- printf("%s", (char[]){'h', 'i', '0'}); What is printed?
- char a = "ab", b = "ab"; printf("%d", strcmp(a, b) == 0); What is printed?
- char buf[8] = "12345"; buf[strlen(buf) - 1] = '0'; printf("%s", buf); What is printed?
- char s[] = "abc"; printf("%c", s[sizeof s - 1]); What is printed?
- printf("%d", (int)sizeof(char)); What is printed in C?
- char w[] = "one two"; char p = w; while (p && p != ' ') p++; printf("%d", (int)(p - w)); What is printed?