Functions in C++ - Reading Assignment

What is a function?
A function is a reusable sequence of data

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

What are return values?
Return values is the value a function return

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

1 Like
  1. A function is a reusable sequence of statements that will execute certain tasks.
  2. int Main() function will run first
  3. Return values are specific values returned from the function.
  4. No hey’re not supported by the language.
1 Like
  1. A function regroups one or several lines of code accomplishing a specific task and can be reused easily.
  2. The main function.
  3. Return values are output variables of a function.
  4. no.
1 Like

1
A function is a sequence of statements designed to do a particular job which include the possibility to call the same function in other parts of the code.

2
the one initiated as ā€œmainā€

3 found in https://www.learncpp.com/cpp-tutorial/function-return-values/
number or strings passed (to the caller) from functions

4
no

1 Like

Answer:

  1. A function is a set of sequential instructions designed to do a specific job.
  2. int main()
  3. Return values are results created by executing functions with a specified type of value. Some functions don’t have return values and only useful for their side effects.
  4. Nested functions are not allowed in C++. Functions in the ā€œmainā€ body function can only be called. The body of the called functions has to be outside of the ā€œmainā€ functions. Preferably before the body of the ā€œmainā€ function.
1 Like
  1. Functions are portions of code used to execute particular tasks and ā€œcompartmentalizeā€ programs.
  2. The main() function.
  3. They are values returned as result of the execution of a function.
  4. No, they are not. To use multiple related function one must write them separately and connect them by using the nested function name within the main one.
1 Like
  1. A function is a piece of code (small program) which can be reused several times and this defined function does something/ performs tasks for you (e. g. calculation, manipulation of data etc. )

2.The first executed function is always the function main().

  1. There are two types of functions in C++. The first returns nothing and just manipulate/calculate something but doesnĀ“t give anything back (the functions are defined through the ā€œwordā€ void. The second functions returns something (a value). When defining such functions which should give something back (a value) you have to write the data type of the results followed by the function name. The returned value of the function can be used for further operations.

  2. Nested functions are not allowed to use in C++

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

  2. The function that is run first is called main.

  3. Return values are the specific values returned from a function.

  4. Functions cannot be defined inside other functions in C++, therefore nested functions are not allowed.

1 Like

What is a function?
A function is a repeatable set of commands grouped together and executed from other functions.

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

What are return values?
This is the output values of the function after each command has been executed.

Are nested functions allowed in C++?
No. Nested function cannot be created in C++. Rather each function needs to be defined separately., Functions can then be called from other functions.

1 Like

1)What is a function?
a reusable portion of code designed to do a particular job.

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

3)What are return values?
values returned to the calling function

4)Are nested functions allowed in C++?
no

1 Like
  1. A piece of code that can be called in program to do a particular job.

  2. main()

  3. values that a function outputs after its execution is completed.

  4. no

1 Like
  1. What is a function?
    A function is essentially a sequence of statements that can be reused when called upon.

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

  3. What are return values?
    The data that is returned after a function is executed

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

1 Like

1.) Reusable sequence of statements designed to do a particular job.

2.) Int main()

3.) output value from a function’s execution.

4.) No nested functions does not compute…compile…both?

1 Like

4. Are nested functions allowed in C++?

Can be both, simply as nested functions are not allowed in C++.

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

Carlos Z.

  1. A function is a grouped set of statements set outside (usually above) the main code section that can be called upon, more than once if required, to process that said function and then return to the next line in the main code (with the function outcome at hand).
  2. Int Main()
  3. Return values are the resulting data/answer from running a function
  4. No
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.

3. What are return values? The specific value returned from a function is called the return value. When the return statement is executed, the return value is copied from the function back to the caller. This process is called return by value.

4. Are nested functions allowed in C++? Unlike some other programming languages, nested functions are not allowed in C++.

1 Like

1. What is a function?

A function is a re-usable sequence of statements designed to do a particular job.

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

Every program must have a function named main which is where the program starts execution when it is run.

3. What are return values?

The specific value returned from a function is called the return value .

4. Are nested functions allowed in C++?

No, functions cannot be defined inside other functions in C++.

1 Like
1. What is a function?

A reusable chunk of code. Ideally it should do exactly 1 thing, no more, no less. All tasks not related that ā€œone thingā€ should be delegated to other functions.

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

int main()

3. What are return values?
  • A return value is the result of a function call
  • Functions must explicitly define the type returned- i.e int or string
  • Functions that don’t result in a value return void
  • If a function declares a return type and no value is returned this will result in ā€œundefined behaviourā€
    • Oddly enough the compiler doesn’t complain. It seems to return an uninitialized value

The following program outputs Foo 1875946688 for me:

#include <iostream>

using namespace std;

int foo() {
    // don't return anything
}

int main()
{
    cout << "Foo " << foo();
    return 0;
}

4. Are nested functions allowed in C++?

Nesting is not supported. The function must instead be declared elsewhere then called.

1 Like
  1. A collection of statements that is reusable
  2. int main(){}
  3. Value that is returned from a function when it is called
  4. Unlike javascript, C++ does not support nested function. Another function can be called inside a different function, however it cannot be defined inside another function
1 Like
  1. A function is a group of statements that the compiler executes if written correctly.

  2. The function that is called ā€œmainā€

  3. A specific value that is returned when executing a function. The specific value
    is specified in its own function.

  4. No

1 Like