LearnFrenzy
Sign in Take a free test

C Variables · Predict the Output · Question 12

C23 auto with 10L, 3u and 1.5f – output Answer, explanation & discussion

  • Output
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What is the output of the following program, compiled as C23 on 64-bit Linux or macOS?

main.c
#include <stdio.h>

int main(void) {
    auto big = 10L;
    auto u = 3u;
    auto d = 1.5f;
    printf("%zu %zu %zu\n", sizeof big, sizeof u, sizeof d);
    return 0;
}
  • A 8 4 4 Correct
  • B 4 4 8
  • C 8 4 8
  • D Compilation error
Correct Answer: Option A

The suffixes decide the deduced types: 10L is a long (8 bytes on LP64), 3u an unsigned int (4) and 1.5f a float (4).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links