answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#include<time.h>

time_t time(time_t *t);

main()

{

int y2,m2,d2,y,m,d;

time_t t = time(NULL);

struct tm tm = *localtime(&t);

printf("Time now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);

y2=tm.tm_year+1900;

m2=tm.tm_mon+1;

d2=tm.tm_mday;

printf("Enter the Reference Date in DD MM YY format\n");

scanf("%d%d%d",&d,&m,&y);

int loop,total_days = 0,days_in_a_year;

int day,month,year;

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

printf("\n%d\n%d\n%d\n",(y2-y),(m2-m),(d2-d));

printf("%d",month_days[m]);

if(((y2-y)==0&&(m2-m)<1&&(d2<d))(y2<y)(m<1)(m>12)(d<0)(d>month_days[m-1]))

{

printf("\nInvalid Reference Date\n");

}

else

{

total_days=month_days[m-1]-d;

if((m==2)&&((y%4)==0))

total_days+=1;

for(int i=m;i<12;i++)

{

if((y%4==0)&&i==1)

total_days+=1;

total_days+=month_days[i];

}

for(int year=y+1;year<y2;year++)

{

if(year%4==0)

total_days+=366;

else

total_days+=365;

}

for(int i=0;i<m2-1;i++)

{

if((y2%4==0)&&i==1)

total_days+=1;

total_days+=month_days[i];

}

total_days+=d2;

if((y2==y)&&(y%4==0))

total_days-=366;

if((y2==y)&&(y%4!=0))

total_days-=365;

}

printf("\nThe date difference is %d\n",total_days);

getch();

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

HOW can a program that outputs the days of the week using switch statement be created?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int n; printf("enter the value of n"); scanf("%d",&amp;n); switch(n) { case1:printf("monday"); break; case2:printf("tueday"); break; case3:printf("wednesday"); break; case4:printf("thursday"); break; case5:printf("friday"); break; case6:printf("saturday"); break; case7:printf("sunday"); break; default:printf("invalid number"); } }


What is Date class in java?

Dates in Java, found in java.util, represent millisecond-precise instants of time. In most cases, it is replaced by java.time APIs, which are used for manipulating dates.


How does Java Script store date in a date object?

JavaScript stores dates in a Date object as the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC, known as the Unix epoch. This representation allows for easy manipulation and comparison of dates. When you create a Date object, it can be initialized with a specific date and time, and JavaScript provides various methods to retrieve and format this information. Internally, the Date object encapsulates this millisecond value, allowing developers to work with dates efficiently.


Why is it important for inventors to keep accurate records including specific dates of the invention process?

Keeping accurate records including specific dates of the invention process is important because it demonstrates, and possibly proves, original work. It can mean the difference between getting credit for a invention and credit being given to another for announcing it earlier even though they used your work. It can also be a decisive factor in determining who gets a patent and benefits financially for an invention.


When is the Next intake dates at the Kenya polytechnic college?

september

Related Questions

How do you calculate the number of days between two dates including weekends and bank holidays?

For Excel:Format A1 and A2 in the date format you prefer.Put your first date in A1 and your second date in A2.In A3, put the following formula: =A2-A1Observe the number of days between the two dates displayed in A3.


How do you get the answer to the question How many times did earth orbit the sun between 140ce and 1543?

-- Calculate the total number of years between those dates. -- That number will be reasonably close to the answer itself, since "orbit the sun" is just a more technical term for "year". A more accurate figure will involve the considerable tinkering with the calendar that went on during that period. The simple (140 + 1543) might not be accurate, but the first step given above still holds: Calculate the actual total number of years between those dates, and you'll have the number you're looking for.


How do you find the number of years weeks days between two dates you need this for calculating the amount of time from hire in date to todays date that an employee has been with the company?

Use excel. You need two cells with the dates in them (one with hire date, one with "=TODAY()" in it). Then to calculate the number of days (x), subtract one from the other. You can then create formulae to calculate number of years (=x/365), weeks (=x/7).


How do you calculate the number of days between two dates and return a 0 when cell is null?

-- If the earlier date is in A1 and the later date is in B1, then the number of days between the dates is just [ = B1 - A1 ]. -- Format the cell with [ = B1 - A1 ] in it to display [ number / zero decimal places ]. -- Under [ File / Options / Advanced / ], find the choice on the big list there that says "Display zero in cells with zero value" and check the box.


Where can one find information about time calculator?

Information about a time calculator and what it is capable of doing can be found on the internet. Time calculators work strictly with dates and times to calculate total time or to calculate the difference between dates and times.


How many years in between?

To determine the number of years in between, you'll need two specific years or dates. Subtract the earlier year from the later year. For example, if you're looking at the years 2010 and 2020, the difference is 10 years. If you provide the specific years, I can calculate it for you.


Calculate the number of days from March 3 2009 to May 12 2010?

There are 436 days, inclusive of the dates given.


C program for comparison of dates using structures?

C program for comparison of dates using structures


How do you solve the time between the two given dates?

To calculate the time between two given dates, first determine the earlier and later dates. Subtract the earlier date from the later date using a date calculation tool or manually by counting the days, months, and years. Be mindful of leap years and the varying number of days in different months. The result will give you the total time difference, which can be expressed in days, months, or years.


How many years are between 1912 and 1985?

To calculate the number of years between two dates, you subtract the earlier year from the later year and then subtract 1 if the earlier date is not a full year. In this case, 1985 - 1912 = 73. Since 1912 is not a full year, we subtract 1, resulting in 72 years between 1912 and 1985.


How many years is it between 1992 to 2014?

There have been 22 years in between the year of 1992 and 2014 so anyone born in 1992 will be turning twenty two in the year of 2014. January 1st was on a Monday in 1992 and in 2014, January 1st was on a Wednesday.


How do you find out days and month calculation in Excel?

Arithmetic works with dates and displays the results as days, so just multiply the result times 24 to get the approximate number of hours between the dates (Excel default format for dates assumes each day has a full 24 hours). If your oldest date is in A1 and your most recent date is in A2, use the following formula to calculate hours between the two dates: =(A2-A1)*24.If you need to show exact hours between specific times for two dates, just format A1 and A2 to display both date and time (a standard option under cell format for dates SAMPLE: 1/1/09 12:00 AM).