ProjectSPECCY icon

Guess The Number Game

ProjectSPECCY | PRO | 07/05/17 09:29:38 PM UTC | 0 ⭐ | 210 👁️ | Never ⏰ | []
C++ |

530 B

|

None

|

0 👍

/

0 👎

// Guess the number
// V1.1 by Steve with a little help from Russ
 
 
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
void main()
{
    int guesses = 0;
    int guess = 0;
    srand(time(NULL));
    int number = rand() % 256;
    printf("Guess the number\n");
 
    while (guess != number)
    {
        scanf("%d", &guess);
 
        if (guess > number)
            printf("Lower!\n");
        else if (guess < number)
            printf("higher\n");
            printf("Try again!\n\n");
        guesses++;
    }
    printf("Correct! You got it in %d guesses\n", guesses);
 
    getchar();
}

Comments