• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

My very first C++ program game

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,019
Solutions
1
Reaction score
1,029
Location
United States
This was my very "non-instructional" program I created.
I made this when I first started learning C++ 3 years ago, it's very simple.

It's basically a mind-reading game that correctly guesses your number

Instructions:
  • Pick a number between 1 and 63
  • You will go through 6 phases of numbers
    • In each phase, you need to type 'y' if your number is in the list, 'n' otherwise
  • Then the program will read your mind and reveal your number

Executable:
View attachment 63# Magic.rar

Source Code:
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int u, v, w, x, y, z, result;
char num, num2, num3, num4, num5, num6;

int main()
{
		cout << "Think of a number between 1 and 63 and answer each step." << endl;
		cout << endl;
		cout << "Is your number in here?" << endl;
		cout << "\n1, 3, 5, 7, 9, 11, 13, 15" << endl;
		cout << "17, 19, 21, 23, 25, 27" << endl;
		cout << "29, 31, 33, 35, 37, 39" << endl;
		cout << "41, 43, 45, 47, 49, 51" << endl;
		cout << "53, 55, 57, 59, 61, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num;
		if (!( num != 'Y' && num != 'y'))
			u = 1;

		cout << "\nIs your number in here?" << endl;
		cout << "\n2, 3, 6, 7, 10, 11, 14, 15" << endl;
		cout << "18, 19, 22, 23, 26, 27" << endl;
		cout << "30, 31, 34, 35, 38, 39" << endl;
		cout << "42, 43, 46, 47, 50, 51" << endl;
		cout << "54, 55, 58, 59, 62, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num2;
		if (!( num2 != 'Y' && num2 != 'y'))
			v = 2;

		cout << "\nIs your number in here?" << endl;
		cout << "\n4, 5, 6, 7, 12, 13, 14, 15" << endl;
		cout << "20, 21, 22, 23, 28, 29" << endl;
		cout << "30, 31, 36, 37, 38, 39" << endl;
		cout << "44, 45, 46, 47, 52, 53" << endl;
		cout << "54, 55, 60, 61, 62, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num3;
		if (!( num3 != 'Y' && num3 != 'y'))
			w = 4;

		cout << "\nIs your number in here?" << endl;
		cout << "\n8, 9, 10, 11, 12, 13, 14, 15" << endl;
		cout << "24, 25, 26, 27, 28, 29" << endl;
		cout << "30, 31, 40, 41, 42, 43" << endl;
		cout << "44, 45, 46, 47, 56, 57" << endl;
		cout << "58, 59, 60, 61, 62, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num4;
		if (!( num4 != 'Y' && num4 != 'y'))
			x = 8;

		cout << "\nIs your number in here?" << endl;
		cout << "\n16, 17, 18, 19, 20, 21, 22, 23" << endl;
		cout << "24, 25, 26, 27, 28, 29" << endl;
		cout << "30, 31, 48, 49, 50, 51" << endl;
		cout << "52, 53, 54, 55, 56, 57" << endl;
		cout << "58, 59, 60, 61, 62, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num5;
		if (!( num5 != 'Y' && num5 != 'y'))
			y = 16;

		cout << "\nIs your number in here?" << endl;
		cout << "\n32, 33, 34, 35, 36, 37, 38, 39" << endl;
		cout << "40, 41, 42, 43, 44, 45" << endl;
		cout << "46, 47, 48, 49, 50, 51" << endl;
		cout << "52, 53, 54, 55, 56, 57" << endl;
		cout << "58, 59, 60, 61, 62, 63" << endl;
		cout << " " << endl;
		cout << "y/n?" << endl;
		cout << " " << endl;
		cin >> num6;
		if (!( num6 != 'Y' && num6 != 'y'))
			z = 32;

		result = u+v+w+x+y+z;
		cout << "\nYour secret number is " << result << "." << endl;
		cout << endl;

	system("pause");
}

Lol, it's funny, looking back at these codes 3 years later... oh how I was a noob...
 
Thats my first game, or second, cant remember: BombermAnia.7z - Speedy Share - upload your files here
Still not finished tho.

Golden Shovel for me please.
 
lawl i make this same with Python only with one week study it, but this codes was great for starting learning a new languange program, simple and easy to modify and learn, thanks for share it, Evan.
 
Back
Top