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



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

Answer / 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

More C Interview Questions

code for copying two strings with out strcpy() function.

6 Answers  


what are advantages of U D F?

1 Answers   Google,


what is the value of 'i'? i=strlen("Blue")+strlen("People")/strlen("Red")-strlen("green")

7 Answers   Cadence, JNTU, Zen Technologies,


When should structures be passed by values or by references?

0 Answers   Adobe,


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

0 Answers  






what is the purpose of the code, and is there any problem with it. unsigned int v[10]; unsigned int i = 0; while (i < 10) v[i] = i++;

2 Answers   Google,


main() { intx=2,y=6,z=6; x=y=z; printf(%d",x) }

5 Answers   Amazon, HCL, Thought Works,


Which is best linux os?

0 Answers  


write a program to remove occurrences the word from entered text?

1 Answers  


Is c call by value?

0 Answers  


2. What does static variable mean?

2 Answers  


What is getche() function?

0 Answers  


Categories