C LANGUAGE - 22: GUESSING GAME
GUESSING GAME:
#include<stdio.h>
#include<stdlib.h>
int main() {
int secretNum = 5;
int guess;
int guessCount=0;
int guessLimit=3;
int OutofGuesses=0;
while(guess != secretNum && OutofGuesses == 0){
if(guessCount<guessLimit){
printf("Enter a Number: ");
scanf("%d", &guess);
guessCount++;
} else {
OutofGuesses = 1;
}
}
if(OutofGuesses == 1){
printf("Out Of Guesses");
} else {
printf("YOU WIN :-) !");
}
return 0;
}
Comments
Post a Comment