LearnFrenzy
Sign in Take a free test

Strings · Exercise 2 of 4

Strings Predict the Output

  • 12 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Read each program and choose what it prints. Every program was compiled and run, so the answers are the real output. Assume a 64-bit system.

Question 11 Hard

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    printf("%zu %zu\n", sizeof 'A', sizeof ((char) 'A'));
    return 0;
}
A 1 1
B 4 1
C 4 4
D 1 4
Question page & discussion
Question 12 Hard

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    char buf[5];
    long value = 1234567;
    int n = snprintf(buf, sizeof buf, "%ld", value);
    printf("%d %s\n", n, buf);
    return 0;
}
A 4 1234
B 7 1234
C 5 12345
D 7 12345
Question page & discussion
Up next · Exercise 3Find the Error8 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links