Hi I am kind of stuck on one aspect of a project that I am currently working on. I have a code for a number guessing game in "C" I need the program to ask the player if they want to play again after the game is done and. I have everything writen right but somthing is worng please help.
smrhab 0 Newbie Poster
Recommended Answers
Jump to Post#include<stdio.h> #include<stdlib.h> #include<time.h> int main(void) { int runagain=0; srand(time(NULL)); int randnum=rand()%100 +1; int guess=0; do{ printf("Enter a number between 1 and 100\n"); scanf("%d",& guess); if (guess<randnum) printf(" to low enter higher number"); if (guess > randnum) printf("to high enter lower number"); if(guess==randnum) printf( "You got it!\n"); printf("wolud …
Jump to Postok it works but when the game ask would you like to play again you type yes it repeats and the same guesse number repeats. What I mean is that lets say u got the guessed number right and its 30 the second time it ask if you want to …
Jump to PostI did that but it is generateing new number every time it ask enter a number
Well, that's because it is starting a new game. So do you want the person to have more than one guess for an individual game? If so, you would need some type of nested …
Jump to PostWhat you need, in addition to learning how to use CODE tags, is two loops. Loop 1 is for each game. Inside that loop is loop 2 for each guess. You are using one loop for guessing and winning which is very difficult to handle.
The first thing …
All 14 Replies
plgriffith 0 Junior Poster
smrhab 0 Newbie Poster
smrhab 0 Newbie Poster
smrhab 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
smrhab 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
smrhab 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
smrhab 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
smrhab 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
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.