Ask Experts » Computers » Software »

C program to Find difference between the dates

Date: 06 Jan 2010   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



Find Answers

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
Answers      





Post answer or solution to "C program to Find difference between the dates"

You can earn revenue online from Google AdSense and our revenue sharing programs by post valid, self written answers for the problem C program to Find difference between the dates




You must Sign In to post a response.


Next Question: C program to get 3*3 matrix as input and display result in 4*4 matrix wit 4th row and column diplay
Previous Question: C program to find largest element in the row and column of matrix
Return to Question Index
Ask Question to Expert
Category: Software

 
Related Questions
Popular Tags   What are tags ?   Search Tags  

Awards & Gifts
Active Members
TodayLast 7 Daysmore...

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