Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace::std;
- void prototypefunction();
- int main(){
- int choice;
- int list[1];
- list[0] = 1;
- list[1] = 2;
- int x = list[0];
- int y = list[1];
- int z = list[0] + list[1];
- system("cls");
- cout << "Simple C++ example's, coded by Harry Laurent" << endl;
- cout << "--------------------------------------------" << endl;
- cout << "1. Call a simple function to display a message." << endl;
- cout << "2. Simple variables math." << endl;
- cout << "3. Exit Program" << endl;
- cin >> choice;
- if(choice == 1){
- prototypefunction();
- }
- if(choice == 2){
- system("cls");
- cout << "The value of x + y = z, z = " << z << endl;
- system("pause");
- return main();
- }
- if(choice == 3){
- exit(1);
- }
- if(choice != 1 && choice != 2 && choice != 3 || choice == 'null'){
- system("cls");
- cout << "Invalid option, please try again." << endl;
- system("pause");
- return main();
- }
- return main();
- }
- void prototypefunction(){
- system("cls");
- cout << "This message is displayed using a function" << endl;
- system("pause");
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment