Start learning free

LESSON 39 OF 667 · FUNCTIONS I

Exercise: Create Function with Parameters in C++

Practice

We've written this code:

void mainFunction() {
	cout << "My name is Andy" << endl;
	cout << "I code in Python" << endl;
	cout << "I have a dog" << endl;

	cout << "My name is Mike" << endl;
	cout << "I code in Java" << endl;
	cout << "I have a cat" << endl;

	cout << "My name is Sarah" << endl;
	cout << "I code in JavaScript" << endl;
	cout << "I have a parrot" << endl;
}

Write the same code in a better way by creating and calling a function with parameters printMessages()

STEP 1 OF 5
    Ctrl + Enter to check