ProgrammingModerate
char b[16]; sprintf(b, "%d%%", 50); printf("%zu", strlen(b)); What is printed?
- A. 2
- B. 4
- C. 3
- D. 5
Correct answer: C. 3
%% produces one literal percent sign, so the text is '50%' with three characters.
More C Programming questions
- printf("%c", 321); What is printed?
- char a[20], b[20]; / stdin: "hi therennextn" / scanf("%s", a); fgets(b, sizeof b, stdin); What is stored in b?
- char w[] = "ab", z[2] = "ab"; printf("%zu", sizeof w + sizeof z); What is printed?
- For a string s of length up to 2 x 10^5 stored in a char array, which in-place reversal is correct and fast enough?
- What is the value of sizeof("hello") in C?
- char buf[] = "abcn"; buf[strcspn(buf, "n")] = '0'; printf("%zu", strlen(buf)); What is printed?