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

Define Array of pointers.

0 Answers  


WAP to convert text into its ASCII Code and also write a function to decode the text given?

2 Answers  


Where does the name "C" come from, anyway?

0 Answers   Celstream,


what is the difference between static variable and register variable?

3 Answers  


How can you find out how much memory is available?

0 Answers  






What is the argument of a function in c?

0 Answers  


Tell me is null always defined as 0(zero)?

0 Answers  


Which header file is essential for using strcmp function?

0 Answers  


How can you avoid including a header more than once?

0 Answers  


Input any no. and print all the the numbers that comes before it like this for e.g input = 4 0 01 012 0123 01234 plz answer it 2day

3 Answers  


A program to allow an input operand and operator from the operator and read on the display and output operand.

0 Answers  


how can i get this by using for loop? * ** * **** * ******

3 Answers   Excel,


Categories