Day Guesser

#include <stdio.h>
int play2(result)
{
    char ch;
    printf("\n\n2  3   6  7\n10  11  14  15\n18  19  22  23\n26  27  30  31\n");
    printf("\nIs Your Birthdate in This List?(y/n)\n");
    scanf(" %c",&ch);
    if(ch=='y')
    {
        result=result+2;
        play3(result);

    }
    else
        play3(result);

}
int play3(int result)
{
    char ch;
    printf("\n\n4  5   6  7\n12  13  14  15\n20  21  22  23\n28  29  30  31\n");
    printf("\nIs Your Birthdate in This List?(y/n)\n");
    scanf(" %c",&ch);
    if(ch=='y')
    {
        result=result+4;
        play4(result);
    }
    else
        play4(result);
}
int play4(int result)
{
    char ch;
    printf("8  9   10  11\n12  13  14  15\n24  25  26  27\n28  29  30  31\n");
    printf("\nIs Your Birthdate in This List?(y/n)\n");
    scanf(" %c",&ch);
    if(ch=='y')
    {
        result=result+8;
        play5(result);
    }
    else
        play5(result);

}
int play5(int result)
{
    char ch;
    printf("16  17   18  19\n20  21  22  23\n24  25  26  27\n28  29  30  31\n");
    printf("\nIs Your Birthdate in This List?(y/n)\n");
    scanf(" %c",&ch);
    if(ch=='y')
    {
        result=result+16;
    }
    date(result);
}
int date(int result)
{
    int n;
    printf("YOUR BIRTHDATE IS=%d\n\n\n",result);
    printf("1. Play\n");
    printf("2. Exit\n");
    scanf("%d",&n);
    while(1)
    {
        switch(n)
        {
        case 1:
            play1();
            break;
        case 2:
            exit(0);
        }
    }
}





int play1()
{
    int result=0;
    char ch;
    printf("\n\n1  3   5  7\n9  11  13  15\n17  19  21  23\n25  27  29  31\n");
    printf("\nIs Your Birthdate in This List?(y/n)\n");
    scanf(" %c",&ch);
    if(ch=='y')
    {
        result=result+1;
        play2(result);
    }
    else
        play2(result);





}
int main()
{
    int n;
    printf("1. Play\n");
    printf("2. Exit\n");
    scanf("%d",&n);
    while(1)
    {
        switch(n)
        {
        case 1:
            play1();
            break;
        case 2:
            exit(0);
        }
    }
    return 0;

}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment