I am trying to make a program that generates a random number (this part works), and then prints something depending on whether the number is greater or less than 555,555,555. While the correct thing prints if the number is over 555,555,555, nothing at all prints when the number is below 555,555,555.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int rand();
time_t secondsFromEpoch = time(NULL);
srand(secondsFromEpoch);
printf("%d\n", rand());
if (rand() > 555555555) {
printf("hello");
}
else if (rand() < 555555555) {
printf("goodbye");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire