is this programm efficient to find the day of the given date . can it be more normalized ?

Ads

 
 
 

Share on Google+Share on Google+

rajesh kumar jain
is this programm efficient to find the day of the given date . can it be more normalized ?
0 Answer(s)      3 years and 7 months ago
Posted in : Date-Calendar
#include <stdio.h>

int main(void)
{
    int dd,mm,yy,i,leap=0,ordi=0,odd_years,month_days= 0,total ;
    char week[7][10] ;
strcpy(week[0], "Sunday") ;
strcpy(week[1], "Monday") ;
strcpy(week[2], "Tuesday") ;
strcpy(week[3], "Wednesday") ;
strcpy(week[4], "Thursday") ;
strcpy(week[5], "Friday") ;
strcpy(week[6], "Saturday") ;
    int month[12]={31,28,31,30,31,30,31,30,31,30,31,30};
    scanf("%d %d %d",&dd,&mm,&yy);
    for(i=yy-1;i>1;i--)
    {
        if(i%4==0)
        {
            leap+=2;
        }
        else

        ordi++;

        }

    printf("%d %d\n",leap , ordi);
    odd_years = leap+ordi;
    odd_years = odd_years % 7;
    printf("%d\n",odd_years);
    for(i=0;i<mm-1;i++)
    {
        month_days = month_days+ month[i];
    }
    if(yy%4==0)
    {
    month_days++;
    month_days = month_days % 7;


    }
    if(yy%4 !=0)
    {
        month_days = month_days % 7;
    }




    printf("%d\n",month_days);
    dd= dd % 7;
    printf("%d\n",dd);
    total = odd_years+month_days+dd;
    total = total %7;
    printf("%d\n",total);
    printf("the day is %s",week[total]);

    // your code goes here
    return 0;
}
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training is this programm efficient to find the day of the given date . can it be more normalized ? date program What is License Terms for using your code current date set date date Cannot convert 1/23/13 1:18 PM of type class java.util.Date to class java.sql.Timestamp Dyanmically Adding Rows with Date Picker Dyanmically Adding Rows Calender in JSP Calender in JSP richfaces jsf how to convert the entire column field of table to dd/mm/yyyy format in microsoft sql server? Database Countdown timer to show a link Find whether a date will be in the current quarter or the next quarter prudhvi code Buy Flowers Online i want to create dynamic calendar in java i want to create dynamic calendar in java date Addintion in year fields of sql date in a java page storing date from html form to oracle 10g using servlet code can u help me to get a calendar with color codes on days ??? html retrieve value from db in text box + calendar implementation. How to add two calendars on the same html page validationrule for date as format yyyy-mm-dd in drools java program program jquery date picker database mysql want the code for calender in php+htmal page Reading the Date and time values from excel sheet Baloon Popup in GWT project calender event Only Display Date date and time in awt(java) time get date picker values to a textbox conept - Date Calendar How to display current date in textbox - Date Calendar this is my code java - Date Calendar ask how function jCalender - Date Calendar Set Date limit for dojo date picker dynamically - Date Calendar

Ads

 
Advertisement null

Ads