I created a random number game where the user tries to guess the number using a while statement with three ifs in it for high low and correct number. but after the user guesses the the number it ends the while and the program. How can I make it so the user can guess another number it he or she would like? I was thinking of making the while statement a function and calling it with main. Any guidence would be appreciated.
Thanks,
Rich
RichC 0 Newbie Poster
Recommended Answers
Jump to PostShow us what you have so far, it's much easier that way to help you!
Jump to PostMy bad. Let me know if you can read it now.
OK, now indent your code so it can be read. After every { indent 3-4 spaces, before every } unindent. Can't tell which open brace goes with which close brace with unformatted code.
Jump to PostIs it better now. sorry I did it in a hurry.
#include <iostream> using namespace std; int main() { int number=10; int x; int your_number;; char answer = 'y'; cout<< "\n\nguess the number:\n"; cin >> your_number; while (your_number != number || answer == 'y') { if(number == your_number) …
All 11 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
RichC 0 Newbie Poster
JoBe 36 Posting Pro in Training
samoguz 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
samoguz 0 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
samoguz 0 Newbie Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
RichC 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.