Ask Experts » Computers » Software »

C program to Find difference between the dates


Date: 06 Jan 2010   Posted By: Charu     Group: Computers    Category: Software   

create the structure called date with date month and year as members. Then find the difference between the dates using C program




Author: mustaqeem Ali    11 Jan 2010      Member Level: Silver     Points : 2    Voting Score: 0

// by mustaqeem Ali Ali's Soft Corpo...
// contact @ mustaqeem_2002@indiastudychannel.com


#define TRUE 1
#define FALSE 0

int months_of_year[] = {31,28,31,30,31,30,31,31,30,31,30,31};


int is_leap_year(int year)
{
int result;

if ( (year%4) != 0 ) // or- if ( year%4 )
result = FALSE; // or- if year is not divisible by 4
else if ( (year%400) == 0 ) // or- if ( !(year%400) )
result = TRUE; // or- if year is divisible by 400
else if ( (year%100) == 0 ) // or- if ( !(year%100) )
result = FALSE; // or- if year is divisible by 100
else // (but not by 400, since that case
result = TRUE; // considered already)

return ( result );
}

int number_of_days_in_the_year(int year)
{
return(is_leap_year(year))? 366 : 365;
}


int number_of_days_till_now((int day,int mon,int year)
{
int i,sum=0;
for (i=0;i {
sum+= months_of_year[i];
}
sum+= day;
if(is_leap_year(year) && mon>2)
sum++;
return sum;
}


Reference: http://www.IndiaStudyChannel.com?ref=mustaqeem_2002

Ali_date.c.txt



Post Answer



You must Sign In to post a response.


Post Answer        





Related Questions
  • Return to Question Index
  • Ask Question to Experts

  • Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.