ProgrammingModerate
int n = 0; sscanf(" 42 abc", " %d", &n); printf("%d", n); What is printed?
- A. 0
- B. 4
- C. 42
- D. 2
Correct answer: C. 42
The leading space in the format skips the whitespace, then %d reads 42.
More C Programming questions
- char a[] = "Level"; int pal = 1; for (int i = 0, j = 4; i < j; i++, j--) if (a[i] != a[j]) pal = 0; printf("%d", pal); What is printed?
- 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)…
- 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)?