guessing game do while loop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Inlcudes
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <ctime>
#include <cstdlib>
using namespace std;

// Main Function
int main()
{
	srand ((unsigned int) time(NULL));
	int num;
	int num2 = 1 + rand() % 100;

	cout << "This program is a random guessing game.\n\n";

	do
	{
		cout << "Enter your guess (1-100): ";
		cin >> num;

		if ( num < num2 )
		{
			cout << "Too Low, Try Again." << endl;
		}
		else if ( num > num2 )
		{
			cout << "Too High, Try Again" << endl;
		}
		else if ( num == num2 )
		{
		  cout << "Congratulations, You Figured Out My Number." << endl;
		}
	} while ( num = num2 );
	
	_getch();

	return 0;
}



Im using a do while only because i feel more comfortable with it in this program, but my problem is it keeps running even after the user has entered the correct number, i need it to stop after the correct number has been entered. Does anyone see the problem.
wow nevermind fixed it, while ( num = num20
had to be change to

while (num != num2)
Topic archived. No new replies allowed.