LearnFrenzy
Sign in Take a free test

Data Types · Predict the Output · Question 8

Octal, hexadecimal and escape literals – output Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What is the output of the following C program on 64-bit Linux or macOS?

main.c
#include <stdio.h>

int main(void) {
    printf("%d %d %c\n", 010, 0x10, '\x41');
    return 0;
}
  • A 10 16 A
  • B 8 16 A Correct
  • C 8 10 A
  • D 10 10 x
Correct Answer: Option B

A leading 0 makes a literal octal (010 = 8) – a common trap with zero-padded numbers. 0x10 is hexadecimal 16, and '\x41' is the character with code 65, 'A'.

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