Write a program with three functions that all use the same global constant. The global constant is the name of a video game: "Fun With Math 2". Each of the functions should output a message that contains this global constant. There is one intro message, one game-exit message, and one game completion message.
Output:
Welcome to Fun With Math 2
This program aims to improve your math skills via interactive games.
Thank you for playing Fun With Math 2
Remember to practice daily!
You have successfully completed all of the activities in Fun With Math 2
Be sure to look out for the 3rd edition of this game (Coming in Summer 2049)!
#include <iostream>
#include <string>
using namespace std;
//Global variable declaration
string name_game = "Fun With Math 2";
void intro(){
cout << "Welcome to " << name_game << endl;
cout << "This program aims to improve your math skills via interactive games." << endl;
}
void game_exit(){
cout << "Thank you for playing " << name_game << endl;
cout << "Remember to practice daily!" << endl;
}
void completion(){
cout << "You have successfully completed all of the activities in " << name_game << endl;
cout << "Be sure to look out for the 3rd edition of this game (Coming in Summer 2049)!" << endl;
}
int main(){
intro();
cout << endl;
game_exit();
cout << endl;
completion();
return 0;
}
Comments
Leave a comment