write a program which will count occurance of a day between
two dates.

Answer Posted / abdul

//calculate num of date bet two dates.
#include<stdio.h>
#include<conio.h>
struct day
{
int date;
int month;
int year;
}x1,x2;
void main()
{
int n_day=0;
clrscr();
printf("\nenter date month and year for x1::");
scanf("%d%d%d",&x1.date,&x1.month,&x1.year);
printf("\nenter date month and year for x2::");
scanf("%d%d%d",&x2.date,&x2.month,&x2.year);
if(x1.year>x2.year)
n_day=n_day+(x1.year-x2.year)*365;
else
n_day=n_day+(x2.year-x1.year)*365;
if(x1.month>x2.month)

n_day=n_day+(x1.month-x2.month)*30;
else
n_day=n_day+(x2.month-x1.month)*30;
if(x1.date>x2.date)
n_day=n_day+(x1.date-x2.date);
else
n_day=n_day+(x2.date-x1.date);
printf("\n\n no. of days between entered two days=%d",n_day);
getch();
}

Is This Answer Correct ?    20 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I copy files?

619


What is the meaning of 2d in c?

607


What is scope and lifetime of a variable in c?

570


Is there a way to compare two structure variables?

615


What is call by value in c?

554






How would you use the functions fseek(), freed(), fwrite() and ftell()?

699


Why is extern used in c?

612


What is the code for 3 questions and answer check in VisualBasic.Net?

1684


What is the deal on sprintf_s return value?

639


What is the modulus operator?

730


Why do we use null pointer?

601


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1539


Why is c not oop?

533


What is the size of enum in bytes?

581


What is atoi and atof in c?

612