Input and Output
We will start off with input and output using intergers (numbers). We will start off this section with a simple guessing game where you guess a number from 1 to 10. First you have to choose a number. The number will be the variable and it is written like this:

int number = 8;
In this case, "number" is the variable and "number" is equal to 8.

int guess;
You also put this down as another variable called "guess". Guess will be the number that the user of the program puts in.

Now you write what ever you want to be displayed on the screen just like this:
cout << "im thinking of a number between 1 and 10\n";
cout << "enter your guess please\n";

For the actual input you write this:
cin >> guess;
whatever the user enters will be equal to "guess".

Your program should look something like this:
Beginning C++
Input, Output and Variables
Operators
Looping
Variables
Functions
#include <iostream.h>
#include <stdlib.h>

int main()
{
int number = 8;
int guess;

cout << "im thinking of a number between 1 and 10\n";
cout << "enter your guess please\n";

cin >> guess;

system("pause");
return 0;
}
Now you need some sort of output or response from your program. We need to make a response if the guess is right and another response if the guess is wrong. We do that using "if", "else", and "else if" statements. "if" will give us one response if the input (guess) is equal to our number which is 8 (number). We will use the "else" statement in this case because if they choose a wrong number, we only need one response and "else" gives us a response that we choose for any input other then 8 (number). If we wanted our program to say something different for each number, we would use an "else if" statement for every different number the user puts in. Heres what our program looks like now:
#include <iostream.h>
#include <stdlib.h>

int main()
{
int number = 8;
int guess;

cout << "im thinking of a number between 1 and 10\n";
cout << "enter your guess please\n";

cin >> guess;

if (guess == number) {
cout << "you are correct\n";
}
else {
cout << "sorry try again\n";
}

system("pause");
return 0;
}
write and compile a few programs like this and get the hang of it before moving on to the next tutorial. If you like you can download a small file of the program shown above so you can see how it should look and operate. download it by clicking on the link below.