LearnFrenzy
Sign in Take a free test

Input/Output with cin and cout · Find the Error · Question 5

Error: endl used without std:: after using std::cout Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

The program below does not compile. Which statement correctly describes the problem?

main.cpp
#include <iostream>
using std::cout;

int main() {
    cout << "Done" << endl;
    return 0;
}
  • A cout must also be qualified
  • B Only cout was brought in with using; endl is still std::endl and is undeclared on its own Correct
  • C endl requires <iomanip>
  • D Strings need single quotes
Correct Answer: Option B

A using-declaration imports exactly one name. Add using std::endl;, write std::endl, or simply use '\n'.

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