38 lines
750 B
C
38 lines
750 B
C
#include <luna.h>
|
|
#include <stdio.h>
|
|
#include <sys/syscall.h>
|
|
#include <unistd.h>
|
|
|
|
unsigned long random_year() // Return a year from 1000 to 2500.
|
|
{
|
|
unsigned long result = syscall(SYS_rand);
|
|
return (result % 1500) + 1000;
|
|
}
|
|
|
|
int is_leap(unsigned long year)
|
|
{
|
|
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
printf("Welcome to the Luna Leap Year Program!\n\n");
|
|
|
|
sleep(1);
|
|
|
|
printf("Choosing a random year between 1000 and 2500... ");
|
|
|
|
msleep(500);
|
|
|
|
unsigned long year = random_year();
|
|
|
|
printf("%lu!\n\n", year);
|
|
|
|
sleep(1);
|
|
|
|
printf("%lu is %s\n", year, is_leap(year) ? "a leap year!" : "not a leap year :(");
|
|
|
|
msleep(500);
|
|
|
|
printf("Press any key to restart.\n");
|
|
} |