Start learning free

LESSON 34 OF 667 · FUNCTIONS I

Exercise: Create Function in C++

Practice

We've wrritten this code:

void mainFunction() {
	cout << "Hello AlgoCademy!" << endl;
	cout << "Coding is amazing!" << endl;
	cout << "Functions are so useful!" << endl;

	cout << "Hello AlgoCademy!" << endl;
	cout << "Coding is amazing!" << endl;
	cout << "Functions are so useful!" << endl;

	cout << "Hello AlgoCademy!" << endl;
	cout << "Coding is amazing!" << endl;
	cout << "Functions are so useful!" << endl;
}

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

STEP 1 OF 5
    Ctrl + Enter to check