Skittles problem C Program

How to write a C Program to Skittles problem in C Programming Language ?


#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
    srand(time(NULL));

    int skittles = rand() % 1024;

    printf("Can you guess what number im thinking of?\n");
    printf ("Take a guess!:  ");
    int guess = GetInt();
    
    
    
    while (guess != skittles)
{
    int difference = skittles - guess;
    printf("\n");
    
        if (difference >= 200)
        {
            printf("There are way more skittles than that!\n");
            printf ("Take another guess!:  ");
            guess = GetInt();
            difference = skittles - guess;
        }
        else if (difference <= -200)
        {
            printf("There are way less skittles than that!\n"); 
            printf ("Take another guess!:  ");
            guess = GetInt();
            difference = skittles - guess;
        }
        else if ((difference >= 1) && (difference < 200))
        {
            printf("A little more!\n");
            printf ("Take another guess!:  ");
            guess = GetInt();
            difference = skittles - guess;
        }
        else if ((difference <= -1) && (difference > -200))
        {
            printf("A little less!\n");
            printf ("Take another guess!:  ");
            guess = GetInt();
            difference = skittles - guess;
        }
     
}
 
     printf("You got it! %i\n", skittles);

}


Learn More :