/*
Lauren Dukes
CPSC 1110 example

The computer is thinking of a number between 1 and 10. 
The user has five tries to guess it.
Uses a for-loop with a complex condition.
*/

#include <stdio.h>
#include <stdbool.h>

int main (void){
	//have the computer pick a number
	int x = 4;

	//declare a variable to hold the user guess
	int guess = 0;

	//get the user's first guess
	printf("I'm thinking of a number between 1 and 10. Guess what it is: ");
	scanf("%d",&guess);

	int nGuesses = 0;
	bool guessedIt = false;
	//while the user hasn't guessed four (more) times yet, and while they haven't guessed it
	for (nGuesses = 0; nGuesses < 4 && !guessedIt; nGuesses++){
		//check to see if the user guessed it
		if (guess == x){
			//if they did, set guessedIt to true
			guessedIt = true;
			printf("You guessed it!\n");
		}
		//otherwise prompt for another guess
		else{
			printf("Nope! Guess again: ");
			scanf("%d",&guess);
		}
	}
	return 0;
}

