G
gambler
Guest
hello,
this is my first time at this place- just wanted to know if I could get some serious programming help. I've got a problem with this program -I've been workn' on it for like five days!!-As of now it's an infinite loop!!!-any suggestions? ( I know very little C++ and not any C!!)
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
using std::endl;
double guessed_num;
char response;
double rand_num;
double i;
int main()
{
rand_num = 1+ rand() % 1000;
do
{
cout << "I have a number between 1 & 1000.";
cout << "\nCan you guess my number?";
cout << "\n\nPlease type your first guess: ";
cin >> guessed_num;
if(guessed_num < 1 || guessed_num > 1000)
{
cout << "\nPlease enter a number between 1 & 1000";
cin >> guessed_num;
}
while (guessed_num != rand_num)
{
if(guessed_num < rand_num)
cout << "\nToo low. Try again.";
else if(guessed_num > rand_num)
cout << "\nToo high. Try again.";
}
cout<< "Excellent You've guessed the correct
number";
cout<< "would you like to play again (y or n)?";
cin >> response;
} while(response != 'n')
return 0;
}
this is my first time at this place- just wanted to know if I could get some serious programming help. I've got a problem with this program -I've been workn' on it for like five days!!-As of now it's an infinite loop!!!-any suggestions? ( I know very little C++ and not any C!!)
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
using std::endl;
double guessed_num;
char response;
double rand_num;
double i;
int main()
{
rand_num = 1+ rand() % 1000;
do
{
cout << "I have a number between 1 & 1000.";
cout << "\nCan you guess my number?";
cout << "\n\nPlease type your first guess: ";
cin >> guessed_num;
if(guessed_num < 1 || guessed_num > 1000)
{
cout << "\nPlease enter a number between 1 & 1000";
cin >> guessed_num;
}
while (guessed_num != rand_num)
{
if(guessed_num < rand_num)
cout << "\nToo low. Try again.";
else if(guessed_num > rand_num)
cout << "\nToo high. Try again.";
}
cout<< "Excellent You've guessed the correct
number";
cout<< "would you like to play again (y or n)?";
cin >> response;
} while(response != 'n')
return 0;
}