1. 단순 guess
#include <stdio.h>
#include <stdlib.h>

int main()
{
		int secretNumber = 5;
		int guess;

	//	사용자가 임의의 숫자를 적어 넣어 정답을 유추한다. //
	//	정답을 맞출 때 까지 while loop를 반복한다. //
	//	정답을 맞추면 'You Win!' 메세지를 보여준다. //

		while(guess != secretNumber){   
				printf("Enter a number:");
				scanf("%d", &guess);
		}
		printf("You Win!");

		return 0;
}
  1. Gamification
#include <stdio.h>
#include <stdlib.h>

int main()
{
		int secretNumber = 5;
		int guess;
		int guessCount = 0;
		int GuessLimit = 3;
		int outOfGuesses = 0;

		while(guess != secretNumber && outOfGuesses == 0){
				if(guessCount < guessLimit && outOfGuesses == 0){ // 도전 가능 //
						printf("Enter a number:");
						scanf("%d", &guess);
						guessCount++;
				} else {  // guessLimit에 도달. 더 이상 도전 불가능 //
						outOfGuesses = 1;  // Boolean (0=False, 1=True) //
				}
		}
		if(outOfGuesses == 1){
				printf("Out of guesses");
		} else{
		printf("You Win!");
		}

		return 0;
}

When guess attempts run out:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7cbd48cc-d028-4b34-84d8-786c988b35d4/Untitled.png

Guessed correctly:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ec964e7d-d356-46aa-9fba-1c7d8cee286e/Untitled.png