bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/C++/C++ Functions
C++•C++ Functions

C++ Multiple Parameters

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind C++ Multiple Parameters?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ myFunction( string fname, int age ) {
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Note that when you are working with multiple parameters, the function call must have the same number of arguments as there are parameters, and the arguments must be passed in the same order.
Inside the function, you can add as many parameters as you want:
Multiple Parameters

Multiple Parameters

Inside the function, you can add as many parameters as you want:

Example

void myFunction( string fname, int age ) {
  cout << fname << " Refsnes. " << age << " years old. \n";
}
int main() {
  myFunction( "Liam", 3 );
  myFunction( "Jenny", 14 );
  myFunction( "Anja", 30 );
  return 0;
}
// Liam Refsnes. 3 years old. // Jenny Refsnes. 14 years old. // Anja Refsnes. 30 years old.

Note that when you are working with multiple parameters, the function call must have the same number of arguments as there are parameters, and the arguments must be passed in the same order.

Previous

C++ Default Parameters

Next

C++ The Return Keyword