# Thread: need help with this problem

1. ## need help with this problem

Write an astrology program.

The user types in a birthday, and the program responds with the sign and horoscope for that birthday. The month may be entered as a number from 1 to 12. Then, enhance your program so that if the birthday is only one or two days away from an adjacent sign, the program announces that the birthday is on a “cusp” and also outputs the horoscope for that nearest adjacent sign.

This program will have a long multiway branch. Make up a horoscope for each sign. Your program should include a loop that lets the user repeat this calculation until the user says she or he is done.

The horoscope signs and dates are:
Sign Dates
Aries March 21 – April 19
Taurus April 20 – May 20
Gemini May 21 – June 21
Cancer June 22 – July 22
Leo July 23 – August 22
Virgo August 23 – September 22
Libra September 23 – October 22
Scorpio October 23 – November 21
Sagittarius November 22 – December 21
Capricorn December 22 – January 19
Aquarius January 20 – February 18
Pisces February 19 – March 20

Code:
```//Header file section
#include<stdio.h>
//Begin main function
int main (void)
{
//Variable declartion
int month, date;
int startdate,startmonth,enddate,endmonth;
char continues;
do
{
//Inputting day
printf("Enter the day of month for your birthday\n");
scanf("%d",date);
//Inputting month
printf(" Entre month of your birthday\n");
scanf("%d",month);
if(month>12 || date>31)
printf("Invalid input\n");

{
startdate = 21;
enddate = 19;
startmonth = 3;
endmonth = 4;
if(( month == startmonth && date >= startdate)||(month == endmonth && date <= enddate))
{
printf("Your Sign is : aries \n");
if(date >= enddate-3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Taurus \n");
else if(date <= startdate +3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Pieces \n");
}
startdate = 20;
enddate = 20;
startmonth = 4;
endmonth = 5;
if(( month == startmonth && date>= startdate)||(month ==endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf(" you are a cusp baby and with adjacent sign: Gemini \n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Aries \n");
}
startdate = 21;
enddate = 21;
startmonth = 5;
endmonth = 6;
if(( month == startmonth && date >= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign:Cancer \n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign:Taurus \n");
}
startdate = 22;
enddate = 22;
startmonth = 6;
endmonth = 7;
if(( month == startmonth && date >= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Leo\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Gemini\n");
}
startdate = 23;
enddate = 22;
startmonth = 7;
endmonth = 8;
if(( month == startmonth && date >= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Virgo\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Cancer\n");
}
startdate = 23;
enddate = 22;
startmonth = 8;
endmonth = 9;
if(( month == startmonth && date>= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Libra\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Leo\n");
}
startdate = 23;
enddate = 22;
startmonth = 9;
endmonth = 10;
if(( month == startmonth && date>= startdate)||(month ==endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Scorpio\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Virgo\n");
}
startdate =23;
enddate = 21;
startmonth = 10;
endmonth = 11;
if(( month== startmonth && date>= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth )
printf("you are a cusp baby and with adjacent sign: Sagitarius\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Libra\n");
}
startdate =22;
enddate = 21;
startmonth = 11;
endmonth = 12;
if(( month== startmonth && date>= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Sagitarius\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Libra\n");
}
startdate = 22;
enddate = 19;
startmonth = 12;
endmonth = 1;
if(( month== startmonth && date>= startdate)||(month ==endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Aquarius\n");
else if(date <= startdate +3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign:Sagittarius\n");
}
startdate = 20;
enddate = 18;
startmonth = 1;
endmonth = 2;
if(( month== startmonth && date>= startdate)||(month ==endmonth && date <= enddate))
{
if(date>= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign: Pisces\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Capricorn\n");
}
startdate = 19;
enddate = 20;
startmonth = 2;
endmonth = 3;
if(( month == startmonth && date >= startdate)||(month == endmonth && date <= enddate))
{
if(date >= enddate - 3 && month == endmonth)
printf("you are a cusp baby and with adjacent sign:Aries\n");
else if(date <= startdate + 3 && month == startmonth)
printf("you are a cusp baby and with adjacent sign: Aquarius \n");
}
}
printf(" To repeat calculations for different variables then press 'y' or 'Y'\n");
scanf("%s",continues);
} while(continues=='y' || continues =='Y');
return 0;
}//End main function```
I can compile the program and run it. But when i enter the input, the error window pop up. Anyone can help me to find out the problem?

2. It's &month and &date for scanf().

3. thank you so much msh
apparently i found out that my loop is not working as well, how to solve it?

4. How about you check all your scanf()'s first? Like the one at the end. There's two mistakes in it.

5. oh for the first mistake, i get it, it should be &continues. What's the second mistake?

6. Read your documentation for scanf(). %s is for getting a string, and if you want to get a string, you need either an array to put it into, or some dynamically allocated memory. Also, for strings, you do not use the 'address of' operator (&) before the name. Since you are looking for a single character, and not a string ('y' or 'Y'), I would suggest that you just do scanf("%c", &some_variable);

Having said all of this, I would suggest that you not use scanf() at all. There are other, less problematic, functions available for getting user input. Have a look at the board FAQ for some ideas.