Code:
// created by M0513027
#include <stdio.h>
struct zodiac
{
char zodiacName[10];
int date1, mon1, date2, mon2;
};
struct month
{
char monthName[30];
int date;
};
main()
{
int d, m, y, a, c=0;
struct zodiac bintang[]=
{
{"Aquarius", 20, 1, 18, 2},
{"Pisces", 19, 2, 20, 3},
{"Aries", 21, 3, 19, 4},
{"Taurus", 20, 4, 20, 5},
{"Gemini", 21, 5, 20, 6},
{"Cancer", 21, 6, 22, 7},
{"Leo", 23, 7, 22, 8},
{"Virgo", 23, 8, 22, 9},
{"Libra", 23, 9, 22, 10},
{"Scorpio", 23, 10, 21, 11},
{"Sagitarius", 22, 11, 21, 12},
{"Capricorn", 22, 12, 19, 1}
};
struct month bulan[]=
{
{"January", 31},
{"February", 28},
{"March", 31},
{"April", 30},
{"May", 31},
{"June", 30},
{"July", 31},
{"August", 31},
{"September", 30},
{"October", 31},
{"November", 30},
{"December", 31},
{"January"}
};
puts("Input your birth date in the following format (dd mm yyyy): ");
scanf("%d %d %d", &d, &m, &y);
if(y%4==0 && y%100!=0 || y%400==0)
bulan[1].date=bulan[1].date+1;
for(a=0; a<12; a++)
{
if(d>=1 && d<=bulan[a].date && d>=bintang[a].date1 && m==bintang[a].mon1)
{
printf("\nYou were born on %d %s %d.\n", d, bulan[a].monthName, y);
printf("You are a/an %s.\n", bintang[a].zodiacName);
c++;
}
else if(d>=1 && d<=bulan[a].date && d<=bintang[a].date2 && m==bintang[a].mon2)
{
printf("\nYou were born on %d %s %d.\n", d, bulan[a+1].monthName, y);
printf("You are a/an %s.\n", bintang[a].zodiacName);
c++;
}
}
if(c==0)
puts("\nSorry, your input is invalid.");
return 0;
}