Friday, 19 April 2019

Program to print day on the date given as input.

#include<stdio.h>
#include<conio.h>

struct date{
    int day,mon,year;
}dat;

int main(){
    int y,f,o_day,od_temp,i,temp,c,o_year,l_year;

    while(1){
        y=0,o_day=0,od_temp=0;temp=0;
        printf("Enter Date (dd/mm/yyyy): ");
        scanf("%d/%d/%d",&dat.day,&dat.mon,&dat.year);

        f=dat.year%4==0 ? 29:28;
        int d[12]={31,f,31,30,31,30,31,31,30,31,30,31};

        while(temp<=dat.year)
            temp+=400;
        if(temp>dat.year)
            temp-=400;
        dat.year-=temp;

        c=(dat.year-dat.year%100)/100;
        od_temp=5*c+c/4;
        od_temp%=7;

        y=dat.year%100-1;
        l_year=y/4;
        o_year=y-l_year;
        od_temp+=(2*l_year+o_year);
        od_temp%=7;

        temp=0;
        for(i=0;i<dat.mon-1;i++)
            temp+=d[i];
        temp+=dat.day;

        od_temp+=temp%7;
        o_day=od_temp%7;

        switch(o_day){
        case 1:
            printf("Monday");
            break;
        case 2:
            printf("Tuesday");
            break;
        case 3:
            printf("Wednesday");
            break;
        case 4:
            printf("Thusday");
            break;
        case 5:
            printf("Friday");
            break;
        case 6:
            printf("Saturday");
            break;
        case 0:
            printf("Sunday");
            break;
        }
        printf("\n\n");
    }
}

1 comment:

  1. Our editors have independently chosen the products listed on this page. If you purchase something talked about in this article, we might earn a small commission. To act with younger boys is loving with out men.What will not poor forsaken women try? When man's not near, the Signior must supply.Signor Dildo was set to music by Michael Nyman for the 2004 wholesale dildo biopic, The Libertine. These are usually worn with condoms to stop them from falling off during use. A docking sleeve is a cylindrical system similar to a penis sleeve, but is open at each ends, so that two men can dock, a form of mutual masturbation.

    ReplyDelete

Featured post

In all other cases the driver is not insured. If the marital status, sex and age of the driver are the inputs, write a program to determine whether the driver is to be insured or not.

  #include #include int main() { char ms;   printf("Is Driver married (Y/N): ");  scanf("%c",&ms);   if(ms=='y&#...

Popular Posts