FAQ: Functions - Return Types — Beyond the Void

This community-built FAQ covers the “Return Types — Beyond the Void” exercise from the lesson “Functions”.

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

Learn C++

FAQs on the exercise Return Types — Beyond the Void

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!

Whether I type ‘true’ or ‘false’ my programs prints 0. What have I missed?

std::cin >> support;
return support;

Probably a bit late, but this is what i found out.

It responds to both 1 [one] or 0 [zero].
For some reason it does not respond to ‘true’ and ‘false’.

1 [one] represent ‘true’ and 0 [zero] represent ‘false’

and by including std::boolalpha in the/a std::cout (meaning you could have std::boolalpha in a seperate std::cout before the actual bool is printed.) you change the output from integers to either ‘true’ or ‘false’. examples:

std::cout << std::boolalpha << needs_it_support() << “\n”;

Hope this is somewhat helpfull.

How was I suppose I had to change the
std::cout <<support:
return support;
This was not what the part one was asking.

Often the answer does not match at all what was ask, English is not my native language but I believe the questions are not well formulated

i keep figuring out answers on my own and by ignoring what the question is asking and peeking at the answer and understand from there.

1 Like

Nothing happens when I click the RUN button. Here is my code:


// Change needs_it_support so that it returns support:
bool needs_it_support() {

bool support;

std::cout << “Hello. IT. Have you tried turning it off and on again? Enter ‘true’ for yes, ‘false’ for no.\n”;
std::cin >> support;
return support;


int main() {

// Change the following line to print the function result:
std::cout << needs_it_support();


It seems that clicking ‘Run’ in this particular exercise doesn’t compile and execute like it did in the previous exercises in the lesson. You can compile and execute the code yourself in the terminal if you like, but the outcome won’t be what is expected. support is a bool variable. When you std::cout << a bool, the output is either a 0 for false or a 1 for true. This particular needs_it_support() function will always return 0 unless the user ignores the instructions, and enters 1. The reason for that may not make sense at this point in the course.
Hope this helps, and happy coding!

Hi! Why are std::string , and std::vector used with std:: in front, while
double , int , bool and char aren’t?

It would take some research to find out why certain data types, built-in methods, etc. are in each particular namespace, but the short answer to your question is that string and vector are not fundamental data types in C++. They are defined in the standard namespace referred to in code as namespace std, so to use them, you have to tell the compiler where to find the definition. Later you’ll start using something called using statements. For example: ( using namespace std; ). This will give you access to all of the items in the standard namespace without having to type std:: before everything belonging to the standard namespace. Hope this helps!

1 Like