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
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
How does sizeof know array size?
Can we use visual studio for c?
Combinations of fibanocci prime series
What are disadvantages of C language.
What is extern c used for?
How do you list a file’s date and time?
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
Can you return null in c?
difference between Low, Middle, High Level languages in c ?
Apart from dennis ritchie who the other person who contributed in design of c language.
What is #line?
The file stdio.h, what does it contain?
Explain how do I determine whether a character is numeric, alphabetic, and so on?