Click here to Skip to main content
15,569,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make a program that takes the birth day and birth month from the user to output corresponding zodiac sign.

I've tried this: "5 1" as an input, but for some reason, I don't get an output.

What I have tried:

C++
#include <stdio.h>

int main()
{

int birth_day, birth_month;

 scanf("%d %d", &birth_day, &birth_month);

if (birth_month == '1')
 {
   if (birth_day < 20)
   {
     printf ("Capricorn\n");
   }
 }
}
Posted
Updated 28-Nov-20 4:12am
v4

1 solution

C++
if (birth_month == '1') // you are trying to compare an int with a char type
// correct code is as follows:
if (birth_month == 1) // integer value 1
 
Share this answer
 
Comments
honey the codewitch 28-Nov-20 7:53am    
Beat me to it
Richard MacCutchan 28-Nov-20 9:42am    
It's daylight here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900