hey can anyone tell me why when the number entered equals the random number, the messages print twice up until the scanf for the character variable g?
Code:
/* Name: Jesse Ranto
 * USER ID: je817659
 * Assignment Number: 3
 * Title: HI-LO Guessing Game
 * Date: 2/11/03
 * Description of the program: Write a C program that plays the HI-LO Guessing game with numbers. The    program should pick a random number between 1 and 100 (inclusive), then repeatedly prompt the user to    guess the number. On each guess, report to the user whether the guess was high or low. Continue       accepting guesses until the user guesses correctly or chooses to quit. Count the number of guesses and    if the user wants to play again. Continue playing games until the user chooses to stop.
*/

#include <stdio.h> //for standard input output
#include <stdlib.h> //for using random functions
#include <time.h> //for using time function
#include <math.h>

int main()

{
	char g;
	int x, y; /*x is the variable for the random number; y is the value for the users entry */
	int c = 1; /*counter*/
	srand(time(NULL)); /*turns on the random generator*/
	x=rand()%100;
	printf("I have a number between 1 and 100 \n");
	printf("Can you guess my number: ");
	scanf("%d", &y);
	while (y != 999) {
		if (y > x) { /*Code runs when guess is higher*/
			printf("Too high. Try again. ");
			printf("Please enter your guess or 999 to quit: ");
			scanf("%d", &y);
			c = c++;
				}
		if (y < x) { /*Code runs when guess is lower*/
			printf("Too low. Try again. ");
			printf("Please enter your guess or 999 to quit: ");
			scanf("%d", &y);
			c = c++;
		 		}
		if (y == x) { /*Code runs when guess equals random number */
			printf("You have found the number. \n");
			printf("You have taken %d guesses. \n", c);
			printf("Would you like to play again? [Y/N] ");
			scanf("%c", &g);
			if (g == 'n' || g == 'N') {
				printf("Thanks for playing. Goodbye. \n");
				return 0;
				                  }
			else if (g == 'y' || g == 'Y') {
				x = rand()%100;
				c = 1;
				printf("The number has been changed. \n Enter your new guess: ");
				scanf("%d", &y);
						}
                               }
			}
		printf("The number was %d. \n", x); /*Code runs when user enters 999 */
		printf("Thanks for playing. Goodbye \n");
		return 0;
			
}


CODE TAGS added by Hammer