Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,894 questions

51,825 answers

573 users

How to get the zodiac sign for a given day and month of birth in C

2 Answers

0 votes
#include <stdio.h>

void print_zodiac_sign(int m, int d) {
    if ((m == 12 && d >= 22) || (m == 1 && d <= 19) ) {  
        printf("Your Zodiac Sign is: Capricorn\n");  
    }  
    else if ((m == 1 && d >= 20) || (m == 2 && d <= 18)) {  
        printf("Your Zodiac Sign is: Aquarius\n");  
    }  
    else if ((m == 2 && d >= 19) || (m == 3 && d <= 20)) {  
        printf("Your Zodiac Sign is: Pisces\n");  
    }  
    else if ((m == 3 && d >= 21) || (m == 4 && d <= 19)) {  
        printf("Your Zodiac Sign is: Aries\n");  
    }  
    else if ((m == 4 && d >= 20) || (m == 5 && d <= 20)) {  
        printf("Your Zodiac Sign is: Taurus\n");  
    }  
    else if ((m == 5 && d >= 21) || (m == 6 && d <= 20)) {  
        printf("Your Zodiac Sign is: Gemini\n");  
    }  
    else if ((m == 6 && d >= 21) || (m == 7 && d <= 22)) {  
        printf("Your Zodiac Sign is: Cancer\n");  
    }  
    else if ((m == 7 && d >= 23) || (m == 8 && d <= 22)) {  
        printf("Your Zodiac Sign is: Leo\n");  
    }  
    else if ((m == 8 && d >= 23) || (m == 9 && d <= 22)) {  
        printf("Your Zodiac Sign is: Virgo\n");  
    }  
    else if ((m == 9 && d >= 23) || (m == 10 && d <= 22)) {  
        printf("Your Zodiac Sign is: Libra\n");  
    }  
    else if ((m == 10 && d >= 23) || (m == 11 && d <= 21)) {  
        printf("Your Zodiac Sign is: Scorpio\n");  
    }  
    else if ((m == 11 && d >= 22) || (m == 12 && d <= 21)) {  
        printf("Your Zodiac Sign is: Sagittarius\n");  
    }  
}

int main()
{
    int m = 2, d = 27;  
    
    print_zodiac_sign(m, d);
   
    return 0;
}



/*
run:
 
Your Zodiac Sign is: Pisces
 
*/

 



answered Jul 13, 2020 by avibootz
edited Oct 28, 2024 by avibootz
0 votes
#include <stdio.h>

const char* getZodiacSign(int day, int month) {
    if ((month == 1 && day >= 20) || (month == 2 && day <= 18)) {
        return "Aquarius";
    } else if ((month == 2 && day >= 19) || (month == 3 && day <= 20)) {
        return "Pisces";
    } else if ((month == 3 && day >= 21) || (month == 4 && day <= 19)) {
        return "Aries";
    } else if ((month == 4 && day >= 20) || (month == 5 && day <= 20)) {
        return "Taurus";
    } else if ((month == 5 && day >= 21) || (month == 6 && day <= 20)) {
        return "Gemini";
    } else if ((month == 6 && day >= 21) || (month == 7 && day <= 22)) {
        return "Cancer";
    } else if ((month == 7 && day >= 23) || (month == 8 && day <= 22)) {
        return "Leo";
    } else if ((month == 8 && day >= 23) || (month == 9 && day <= 22)) {
        return "Virgo";
    } else if ((month == 9 && day >= 23) || (month == 10 && day <= 22)) {
        return "Libra";
    } else if ((month == 10 && day >= 23) || (month == 11 && day <= 21)) {
        return "Scorpio";
    } else if ((month == 11 && day >= 22) || (month == 12 && day <= 21)) {
        return "Sagittarius";
    } else if ((month == 12 && day >= 22) || (month == 1 && day <= 19)) {
        return "Capricorn";
    } else {
        return "Invalid date";
    }
}

int main() {
    int month = 2, day = 27;
    
    printf("Your Zodiac Sign is: %s\n", getZodiacSign(day, month));

    return 0;
}



/*
run:
 
Your Zodiac Sign is: Pisces

*/

 



answered Oct 28, 2024 by avibootz

Related questions

2 answers 96 views
1 answer 194 views
1 answer 125 views
...