--- In [email protected], "Nico Heinze" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "Devils Call me Grand Paa"
> <never_gone007@> wrote:
> >
> > Write a complete program that determine the day number
> > (1to 366) in a year for a date that is provided as input
> > in the format dd-mm-yyyy as an example 01-01-2000 is day
> > 1. 31-12-2001 is the day 365. 31-12-2000 is day 366 because
> > 2000 is leap year. A year is leap year if it is divisible
> > by 4. You may assume that user has entered input in the
> > correct format that is valid date.
>
> I won't give you the code; why should I. But a few hints how to
proceed:
>
> 1) I would copy the input string to a buffer and substitute the two
> dots "." by NUL characters (I'm a C hacker, not C++).
> 2) characters to integer (e.g. characters "25" to integer value
25):
> use strtol(). If you follow my advice above, you can simply feed in
> the three addresses "Buffer", "Buffer + 3", and "Buffer + 6" into
> strtol().
> 3) Your homework question is not 100% correct: a year is a leap
year
> if it is divisible by 4 but not by 100; however, if the year is
> divisible by 400, it IS a leap year (at least with year after 1582,
> the year when the Gregorian Calendar was introduced).
> 4) The easiest way is to first determine whether the given year is
a
> leap year; depending on this value and the number of the month you
can
> identify the max number of days for this month:
> Jan/Mar/May/Jul/Aug/Oct/Dec = 31 days, Apr/Jun/Sep/Nov = 30 days,
Feb
> = 29 days in a leap year, 28 otherwise.
> 5) The remainder is just a bit of adding up.
>
> Any more questions? Show us your code.
>
> Regards,
> Nico
>
#include<iostream>
using namespace std;
void main()
{
int x,year,month,day,arry=
{31,28,31,30,31,30,31,31,30,31,30,31};
cout<<"please enter the year";
cin>>year;
cout<<"please enter the month";
cin>>month;
cout<<"please enter the day";
cin>>day;
if(year%400==0)
{
x=1;
}
for (int i=0;i<month-1<<i++);
{
if(x==1&&i==1)
{
result=result+arry[i]+1;
}
else
{
result=result+arry[i];
}
{
result=result+date;
{
cout<<day;
}
}
// tht is my program but it is not completly right