ProgrammingHard
char a[] = "Level"; int pal = 1; for (int i = 0, j = 4; i < j; i++, j--) if (tolower(a[i]) != tolower(a[j])) pal = 0; printf("%d", pal); What is printed?
- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: A. 1
Lowercasing both characters, L matches l and e matches e, so the palindrome test passes.
More C Programming questions
- printf("[%-6s|]", "ab"); What is printed?
- printf("%+d %05.1f", 5, 3.14159); What is printed?
- char s[] = "abc"; printf("%c", s[strlen(s) - 1]); What is printed?
- char w[] = "ab"; printf("%zu %zu", sizeof w, strlen(w)); What is printed (on any platform)?
- char a = "cat"; char b[] = "cat"; printf("%d", strcmp(a, b) == 0); What is printed?
- char buf[3] = {'a', 'b', 'c'}; printf("%.2s", buf); What is printed?