LearnFrenzy
Sign in Take a free test

C Input / Output · Find the Error · Question 6

Error: putchar("A") with a string Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

The program below has a bug. Which statement correctly describes it?

main.c
#include <stdio.h>

int main(void) {
    putchar("A");
    putchar('\n');
    return 0;
}
  • A putchar needs stdout as an argument
  • B "A" is a string (a char pointer); putchar takes one character, so it should be putchar('A') Correct
  • C putchar returns void
  • D There is no bug
Correct Answer: Option B

Single quotes make a character constant, double quotes a string. To print a whole string use puts() or fputs().

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