Functions in C++ - Reading Assignment

  1. What is a function?
    A reusable sequence of statements structured to carry out operations.

  2. What function is run first of all in a C++ program?
    The main() function.

  3. What are return values?
    The values that a function returns after execution.

  4. Are nested functions allowed in C++?
    They are not. Other functions must be defined outside of other functions.

1 Like

What is a function?

A function is a block of statements which are run sequentially and can either return a value or not. They allow us to break our programs up into smaller modular chunks of reusable code.

What function is run first of all in a C++ program?

The first function to be run is function main() which is best placed at the bottom of all other functions defined in our code.

What are return values?

When we call a function from another function the callee executes a series of statements and if a return statement is used in the callee that function returns the value specified by the return statement to the caller.

Are nested functions allowed in C++?

No nested functions are not allowed in C++

1 Like
  1. A reusable sequence of statements designed to do a particular job.

  2. Caller

  3. The value that a function returns when it is completed.

  4. No

1 Like

A function is a reusable sequence of statements designed to do a particular job.

main function

A functions that returns a value back to the caller

No

1 Like

What function is run first of all in a C++ program?

Not quite right sir, the first function that runs is the main() function.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

It is a sequence of instructions that can be called and executed

main()

They are the final results of a function

No, we have to define functions outside the main() function then we can call them from inside the main() function.

1 Like
  1. Reusable sequence of statements with specific job.
  2. int main(){}
  3. Value that will be returned after calling the function.
  4. No. Functions can’t be defined on another functions.
1 Like
  1. What is a function?
    A function is a reusable sequence of statements designed to do a particular job

  2. What function is run first of all in a C++ program?
    the main() function is where any other function is called out of.

  3. What are return values?
    a value which is returned to the calling function. This value can then further be used in the statements of the calling function

  4. Are nested functions allowed in C++?
    No, nested functions are not allowed

1 Like
  1. What is a function?

A function is a subroutine…a snippet of code that carries out a specific task

  1. What function is run first of all in a C++ program?

MAIN is the chiefest function of functions…the supreme commander of functions…all others are subordinates stemming from the ranks NCO, junior officers to senior…but all subordinate to the grand cahouna

  1. What are return values?

functions contain embedded statements and those statements which, upon execution, produce a value. that ā€˜production’ is called a return value.

it is good that i gave up trying to figure out JS and carry on to C++ because I didn’t get most of this stuff in JS…it is fleshing itself out now.

what I don’t get just yet is how you can have a statement without any arguments…the void function…but I will stay tuned this time and carry on regardless as the answer will likely reveal itself.

  1. Are nested functions allowed in C++?

no, I think you can do this in JS but it is a no no in C++. personally I think this is a good thing as it is easier for my brain to understand, at least at this point. it appears that functions are declared prior to the main function. its like you get to see all the characters in the play before the grand performance. many books and movies would be better understood if they followed this structure…at least for me but I am old school like ā€˜C’ I guess and leave JS, python and all that fancy refined speach to the youngens

1 Like
  1. What is a function?
    A function is a reusable sequence of statements designed to do a particular job.

  2. What function is run first of all in a C++ program?
    int main(){}

  3. What are return values?
    The value that is returned to the calling function.

  4. Are nested functions allowed in C++?
    No.

1 Like

Best answers ever! :smiley: gave me a good laugh 10/10

1 Like

Sometimes its just better to keep quiet and keep the arguments for yourself

1 Like

that’s how a marriage is able to compile…the husband functioning with no arguments whatsoever otherwise it will not compute

1 Like

the husband function can have arguments but its better to pass them as null or you might get runtime errors

1 Like

ah, I get it now. will ensure I pass null for my function in the next programmed marriage…last one scrapped.

1 Like
  1. What is a function?
    A function is a group of sequentially executed statements that are designed to achieve a certain task. This reusable set of directions offered to the computer are wrapped up together in a nice little bundle that allows a user to call on this function any number of times throughout the program.

  2. What function is run first of all in a C++ program?
    The ā€˜main’ function is the first function run in C++ programs. The main function body may call on other functions throughout the program, but always returns to the main function until its completion.

  3. What are return values?
    Return values are values that are produced by a function. This value is returned by a function for use in another part of the program (for example in the ā€˜main’ function or another function, etc.).

  4. Are nested functions allowed in C++?
    Nested functions are illegal in C++. They must be defined separately and can be called on from within other functions as necessary.

1 Like

What is a function?
A function is a reusable sequence of statements designed to do a particular job.
What function is run first of all in a C++ program?
int main() {}
What are return values?
The actual value returned from a function is called the return value
Are nested functions allowed in C++?
No. Functions can not be defined inside other functions (called nesting) in C++.

2 Likes

True :slight_smile: but the question was if these types of functions are allowed in C++? :slight_smile:

1 Like

Thank for pointing that out. I read that question too quick. Yes, nested functions are not supported in C++.

1 Like

Reading Assignment: Functions in C++ questionaire;

What is a function?
// A function is a reusable sequence of statements designed to do a particular job.

What function is run first of all in a C++ program?
// The function main the first one to execute when the source code is ran.

What are return values?
// The specific value returned from a function is called the return value.

Are nested functions allowed in C++?
// Nested functions are not supported in C++.
1 Like