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 |
What is the best way of making my program efficient?
Why is it usually a bad idea to use gets()? Suggest a workaround.
different between overloading and overriding
In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
how to introdu5ce my self in serco
How to write a multi-statement macro?
int a=20; int b=30; int c=40; printf("%d%d%d"); what will be the output?
There is a 100-story building and you are given two eggs. The eggs (and the building) have an interesting property that if you throw the egg from a floor number less than X, it will not break. And it will always brake if the floor number is equal or greater than X. Assuming that you can reuse the eggs which didn't broke; you got to find X in a minimal number of throws. Give an algorithm to find X in minimal number of throws.
main() { charx; while (x=0;x<=255;x++) printf("\nAscii value %d Character %c,x,x); }
write an interactive program to generate the divisors of a given integer.
Why doesnt long int work?
what is develop in c language