FAQ: Compile & Execute - Compile and Execute


This community-built FAQ covers the “Compile and Execute” exercise from the lesson “Compile & Execute”.

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

Learn C++

FAQs on the exercise Compile and Execute

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!


Hi everyone,

I am very confused about the second exercise in C++ compile and execute part:

  1. Q1 asks us to compile hello.cpp

This is the code that I think should be right:

**int main() **

** std::cout << “Hello World!\n”;**
** $ g++ hello.cpp**


Here is the code that the system think is right(nothing has changed compare to the original code)

**int main() **

** std::cout << “Hello World!\n”;**
** $ g++ hello.cpp**

2. Q2 says to execute a.out
This my code, the system told me it was wrong:

**int main() **

** std::cout << “Hello World!\n”;**
** g++ hello.cpp** ** ./a.out**


Not sure about what the correct code is.

  1. When I click on “solution”, it gave me the original code.

hey devwhiz, it’s kind of hard to tell by the formatting of your message, but just to be clear are you typing the compile command in the terminal on the right side of your screen? In bash you should type g++ hello.cpp after the $ that is already there.

Hopefully this helps.

1 Like

Whenever I attempt to compile the code using the following in the terminal
g++ hello.cpp
It does not create a new file called a.out like it is supposed too, this seems to lead on to later problems in the course. I have changed nothing to the default code in the “hello.cpp” file that would cause this issue, and I know that when typing g++ hello.cpp in the terminal that it needs to come after the dollar sign. I do not know if this is just an issue with me or an issue with codeacedmey, Please help me!


same thing happened to me, think its an issue in codecademy’s part. i sent in a bug report about it and hopefully it gets fixed soon

edit: tried entering ./a.out as the 2nd step instructed to, it allowed me to continue. so i think this should not be affecting the exercise?


the thing is just really broken

1 Like

I got the same problem too. I’m just posting to the plataform realize it’s really a bug.

Edit:I did the same thing. The file is not created but if you execute the command it works correctly.


i don’t undersatnd how to compile where i should write g++ ! what it means the terminal where i should write in !
please how did u do to compile