- Code: Select all
GNU nano 2.2.2 File: skittles1.c
#include <cs50.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
// seed PRNG
srand(time(NULL));
//pick psuedorandom number in [0, 1023]
int skittles = 4;
// TODO
printf("There are between 0 and 1023 skittles!\n");
printf("Try to guess how many skittles there are!\n");
int n = GetInt();
do
{
GetInt();
if(n==skittles)
printf("Well Done!\n");
else if(n>=0&&n<skittles)
printf("Your number was too low.\n");
else if(n>skittles&&n<1024)
printf("your number was too high.\n");
else
printf("you chose an invalid number.\n");
}
while(n!=skittles);
return 0;
}
- its supposed to keep going until you get the right number, telling you whether its too high or too low each time.
Any help is appreciated - I've spent quiet floundering around on this now
