Well let me start by showing off my source.
//This is a game called "The Guessing Game"
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int number;
unsigned seed = time(0);
srand(seed);
seed = 1 + rand() % 100;
cout << "Please try to guess a number from 1-100: ";
while(number != seed)
{
cin >> number;
if(number < 1 || number > 100)
cout << "\nNumber is not between 1-100. Try again: ";
else if(number > seed)
cout << "\nNumber is too high! Try again: ";
else if(number < seed)
cout << "\nNumber is too low! Try again: ";
}
cout << "\nThe number was: " << number << endl;
cout << "\nCongratulations! You won the game!\n\n";
system("pause");
return 0;
}
The only thing I need is after the "The number was" statement, I want to cout something else that says how many times the loop executed. So do i need to define a variable for the loop counter? What would be the function that counts the loops?? Thanks in advance!!