How is this?

I've made a really simple, and I mean so painfully simple game, but it's what I can do right now, after some genius thinking I figured out how to do it. Enjoy!

#include "stdafx.h"
#include <iostream>

int main()
using namespace std;
cout << "Hello! We are going to play a game. You say a number, I add 2 to it. Let's go!" << endl;
cout << "Please enter a number: " ;
int y=0;
int x=0;
cin >> y ;
cout << "Your next number is: " << x ;
cout << " Wait! I can show you how good I am. I'll add 4 to THAT number." << endl;
cout << " Please re-enter the number I gave you: " << endl;
int a=0;
int b=0;
cin >> a;
cout << "Huzzah! Your new number is: " << b << endl;
cout << "Thanks for playing!" << endl;
return 0;
-Steals your game-
-Sells it to at&t-
-Makes millions-
-Samsung's Life Story-
Just going to suggest a few things to get in the habit of doing, It looks like your using visual express and using the precompiled header? dont use that, just use empty project. you should only need #include <iostream> and using namespace std; at the top, dont declare namespace inside main like that.

Also give your variables more descriptive names, single letter is terrible, I know its just for you right now, but its good habit to get into.

and you dont have to use system pause, you can put a break at the end or run with out debugging (ctrl+f5) after you build it.

My only comment is that there are lots of variables, x, y, a and b.
However, the program as it stands right now could work just as well with a single variable (say x) used throughout. It's usually best to keep the number of variables small, and only introduce a new variable when it serves a definite purpose.
Topic archived. No new replies allowed.