Guessing Game

Lab C Intermediate 20 points

The secret number is 37. Read guesses until correct: print higher or lower for each wrong guess, then correct in N.

Input

Guesses, one per line; the last is 37.

Output

One line per guess.

Example

Input

50
25
37

Output

lower
higher
correct in 3
Sample input available Sample output available
Editor
C

Hints

while (1) loops until break.

Solution explanation

An infinite loop with a break is the natural shape for "repeat until done".

Show solution
#include <stdio.h>

int main() {
    int secret = 37, guess, tries = 0;
    while (1) {
        scanf("%d", &guess);
        tries++;
        if (guess < secret) {
            printf("higher\n");
        } else if (guess > secret) {
            printf("lower\n");
        } else {
            printf("correct in %d\n", tries);
            break;
        }
    }
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD