LearnFrenzy
Sign in Take a free test

C Input / Output · Predict the Output · Question 5

%c, %x, %#o and %#X with numbers – output Answer, explanation & discussion

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

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    printf("%c %d %x %#o %#X\n", 66, 'a', 255, 8, 255);
    return 0;
}
  • A B 97 ff 010 0XFF Correct
  • B 66 a ff 10 FF
  • C B 97 FF 010 0xff
  • D B a ff 8 0XFF
Correct Answer: Option A

%c prints the character with code 66; %d prints the code of 'a'; %x is lowercase hex; # adds a leading 0 to octal and 0X to uppercase hex.

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