Im copying your comments dudes.... Im learning more on those "indentations for readability" ...(imbecile me)...
now i have to *really* listen..
int *limit[N] ---> wrong
int limit[N] -----> right....!!
i should understand the purpose of an array of "int pointers", and an array of "ints only"...
Im analyzing the points given by Walt P... and yeah ! they're awesome ideas..
Code:
#include <stdio.h>
#define N 12
int main(void)
{
char m[80], *months[N] = {"january", "february", "march", "april", "may",
"june", "july","august", "september", "october",
"november", "december"},
*zodiac[N] = {"CAPRICORN", "AQUARIUS", "PISCES", "ARIES",
"TAURUS", "GEMINI", "CANCER", "LEO", "VIRGO",
"LIBRA", "SCORPIO", "SAGITTARIUS"};
int i, d, limit[N] = { 19, 18, 20, 19, 20, 20, 22, 22, 22, 22, 21, 21 };
clrscr();
printf("enter MONTH of birth: "); gets(m);
printf("enter DATE of birth: "); scanf("%i", &d);
for(i=0; i<N && strcmp(m, months[i]) != 0; i++);
if(d<=limit[i])
printf("%s\n", zodiac[i]);
else
printf("%s\n", zodiac[(i+1)%N]);
getch();
}
--------
or as recommended by Walt P
Code:
#include <stdio.h>
#define N 12
int main(void)
{
char m[80], *months[N] = {"january", "february", "march", "april", "may",
"june", "july","august", "september", "october",
"november", "december"},
*zodiac[N] = {"CAPRICORN", "AQUARIUS", "PISCES", "ARIES",
"TAURUS", "GEMINI", "CANCER", "LEO", "VIRGO",
"LIBRA", "SCORPIO", "SAGITTARIUS"};
int i, d, limit[N] = { 19, 18, 20, 19, 20, 20, 22, 22, 22, 22, 21, 21 };
clrscr();
printf("enter MONTH of birth: "); gets(m);
printf("enter DATE of birth: "); scanf("%i", &d);
for(i=0; i<N && strcmp(m, months[i]) != 0; i++);
if(d>=limit[i]) i++;
if(i>=N) i-=N;
printf("%s\n", zodiac[(i)]);
getch();
}
Great !! WHew !!
===========
that which one learns with difficulty would not be easily forgotten...
especially by an imbecile one..
merci !!