![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2005
Posts: 37
Rep Power: 0
![]() |
running error
I am making that guessing game someone said to make but for some reason it won't appear.
#include <iostream>
using namespace std;
int main ()
{
int n, g, t;
n = 43;
cout << "Welcome to the guessing game! \nThe number I am thinking of is between 1 and 100.";
cout << "Enter the number you wish to guess.\n";
cin >> g;
while (g != n) {
cout << "Guess again! You have attempted to guess " << t << " times.";
}
}
__________________
looking for a teacher, i'm willing to learn any language - my master is jayme |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Well, what do you want to loop? It's not just the "you were wrong" message, is it?
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Nov 2005
Posts: 37
Rep Power: 0
![]() |
well its a guessing game, so its supposed to say you are wrong guess again
__________________
looking for a teacher, i'm willing to learn any language - my master is jayme |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
the input is not in the loop so it will just repeat the message continuously unless the first guess is correct
__________________
www.heldtogether.co.uk |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Nov 2005
Posts: 37
Rep Power: 0
![]() |
oooh! i forgot to add the guess factor.... oops
__________________
looking for a teacher, i'm willing to learn any language - my master is jayme |
|
|
|
|
|
#6 | |
|
Professional Programmer
|
here are my "hints":
1. Give an integer value to t 2. the program will repeat while (g != n) {
cout << "Guess again! You have attempted to guess " << t << " times."; }3. include your 't' integer in that loop.
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Nov 2005
Posts: 37
Rep Power: 0
![]() |
okay i added the guess factor... it is still not appearing on startup
#include <iostream>
using namespace std;
int main ()
{
int n, g, t;
n = 43;
t = 5;
cout << "Welcome to the guessing game! \nThe number I am thinking of is between 1 and 100.";
cout << "Enter the number you wish to guess.\n";
cin >> g;
while (g != n) {
cout << "Guess again! You have attempted to guess " << t << " times.";
cin >> g;
}
cout << "Congratulations! You have guessed the correct number: " << n << ".\n";
cout << "Thank you for participating in my guessing game.";
return 0;
}the 5 by the way is just a random number (because i still have to learn how to read/write a file)
__________________
looking for a teacher, i'm willing to learn any language - my master is jayme |
|
|
|
|
|
#8 | |
|
Professional Programmer
|
get on msn, i added you.. i dont understand what you mean by appearing on startup. Works fine for me, except that you need to fix a few little problems, and the t = t +1 is missing
![]()
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: Nov 2005
Posts: 37
Rep Power: 0
![]() |
once i figure out how to get online on msn... i will
it is rejecting my logon, says something about my internet connection....
__________________
looking for a teacher, i'm willing to learn any language - my master is jayme |
|
|
|
|
|
#10 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
First of all, what's with the one-letter variables? You should know what a variable contains based on its name.
Next, you're not allocating anything to g. For all you know, it might have the number 43 already in it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|