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

Tell me about low level programming languages.

645


What happens if a header file is included twice?

601


What is break in c?

588


What is pass by value in c?

597


What is double pointer in c?

591






hi send me sample aptitude papers of cts?

1654


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

626


Why is c known as a mother language?

750


Write a program with dynamically allocation of variable.

606


What is the data segment that is followed by c?

616


How to Throw some light on the splay trees?

622


Can a pointer be volatile in c?

536


What are the advantages of using Unions?

642


When should the volatile modifier be used?

688


What is a constant and types of constants in c?

605