FAQ: Hello World - Output

This community-built FAQ covers the “Output” exercise from the lesson “Hello World!”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

FAQs on the exercise Output

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Quick question, what does the “std” stand for?

2 Likes

if i google:

c++ std

google provides the answer for me:

C++ Standard Library - Wikipedia

without even having to click on it, the link already has the answer in it

1 Like

“std” stands for standard. Hope this was helpful!

I think it is a c++ standard library the replaces the “using the namespace”

1 Like

When I typed std::cout<<“codecademy\n”; I got the output but not in the case cout<<“codeacademy\n”; … why so??

1 Like

C++ is made up of many libraries. cout belongs to the standard library also referred to as a namespace. cout by itself means nothing. std::cout is referring to cout in the standard namespace. It can get tiring having to type std:: before everything that you want to use from the standard library, so that’s where using statements come in. You probably haven’t gotten to those yet, but in time you will. For now, it’s best to follow the progression of the lessons. Happy coding!

1 Like

this online program that you use to write and run your C+ instractions is programmed to see this word “codecademy” output in the terminal , nothing else ; so it is not related to C++ compiler or not meaning that you have made a mistake

cout will not work without being qualified as an object in the std namespace in one of the following ways:
using declaration:

#include <iostream>
using namespace std;
int main() {
  cout<<"Any text";
}

or explicit qualification:

#include <iostream>
int main() {
  std::cout<<"Any text";
}

Attempting to use cout without qualification will raise an error:
error: 'cout' was not declared in this scope
If you have information to the contrary, please share.

1 Like

Daza007

Hi, why do we have to include wired symbols in any computer languages that we never learnt or heard about this. It really is confusing symbols.

How to write programs in a straightforward instructions with a flow chart as a guide and minimize weird symbols!!!

When typing between the curly braces, does the amount of space between the line of code and the braces matter? In the exercise there are 3 empty lines between { and }. For example

  1. {
  2. (line of code)
  3. }

VS

  1. {
  2. (line of code)
  3. }

only for readability.

2 Likes

So I did all the directions right, but it gave me an error code. What did I do wrong?

Here’s what I did:

What did I do wrong?

1 Like

nevermind I got it now.

What’s the primary purpose of "#include " and “<<” ?

Include directive

From Wikipedia, the free encyclopedia

Include directive

Many programming languages and other computer files have a directive, often called include (as well as copy and import ), that causes the contents of a second file to be inserted into the original file. These included files are called copybooks or header files . They are often used to define the physical layout of program data, pieces of procedural code and/or forward declarations while promoting encapsulation and the reuse of code.

To include code from the include file into another file so you don’t have to duplicate that code.

<< Operator
This operator ( << ) applied to an output stream is known as insertion operator . It is overloaded as a member function for:

  1. arithmetic types

Generates a sequence of characters with the representation of val, properly formatted according to the locale and other formatting settings selected in the stream, and inserts them into the output stream.
Internally, the function accesses the output sequence by first constructing a sentry object. Then (if good), it calls num_put::put (using the stream’s selected locale ) to perform both the formatting and the insertion operations, adjusting the stream’s internal state flags accordingly. Finally, it destroys the sentry object before returning.

(2) stream buffers

Retrieves as many characters as possible from the input sequence controlled by the stream buffer object pointed by sb (if any) and inserts them into the stream, until either the input sequence is exhausted or the function fails to insert into the stream.
Internally, the function accesses the output sequence by first constructing a sentry object. Then (if good), it inserts characters into its associated stream buffer object as if calling its member function sputc, and finally destroys the sentry object before returning.

(3) manipulators

Calls pf(*this) , where pf may be a manipulator .
Manipulators are functions specifically designed to be called when used with this operator.
This operation has no effect on the output sequence and inserts no characters (unless the manipulator itself does, like endl or ends do).

std::operator<< (ostream)

 std::cout<<"Codecademy\n";

Hello, The task of those symbols and their use is kind of vexing to me. Could someone please, please explain to me, why, O why
“::” i.e. double colons
“<<” i.e. double less-than symbols
and lastly, what does “std” even mean?

std means the standard namespace
What is std and what does it means?
Double quotes is how we wrap strings. Single quotes is for characters.
When should I use single quotes and double quotes in C or C++ programming?
<< Is used to for output likewise with >> for input aka I/O.
insertion operator
extraction operator

2 Likes

So if I had to guess, this would be the way to put a single line of code into a namespace