Вы находитесь на странице: 1из 1

1: #include <stdio.

h>
2:
3: int main(void)
4: {
5:
6: int mybday = 18; //declare variable to be guessed
7: int guess; //declare variable to store guessed date
8: int max = 31; //declare variable to test for invalid input
9: int min = 1; //declare variable to test for invalid input
10: int i;
11: char ch;
12:
13: for (i=0; i<5; i++){
14:
15: printf("\n Try to guess the day of my Birthday: "); //display the intro and directions
16: scanf("%d",&guess); //`get the users guess and store it in the variable guess
17:
18: if (guess == mybday)
19: {
20: printf("You Win!!"); //print you win if guess is correct
21: }
22: else if (guess < min)
23: {
24: printf("Thats NOT A DATE!!"); //print `Error for invalid input
25: }
26: else if (guess > max)
27: {
28: printf("There isn't %d days in a month!",guess); //print Error for invalid input
29: }
30: else if (guess > mybday)
31: {
32: printf("Too High!"); //print too high if guess is above answer
33: }
34: else if (guess < mybday)
35: {
36: printf("Too Low!"); //print too low if guess is below answer
37: }
38: else
39: {
40: printf("Try again!!"); //Print try again if guess if all else is not true (not possible)
41: }
42: }
43:
44: getche();
45: return 0;
46: }
47:

Вам также может понравиться