By definition a leap year is any year that is divisible by 4. However if a year is a century year it is only a leap year if it is divisible by 400.
I believe i need a If statement in this program? please help this n00b out :]
EDIT: also he program is going to keep going until a sentinel is entered.
To my knowledge, sentinel is a value that you set to make the program start? is there any more info you can give me? i am new to programming.
Leap Year program
Started by Gz1987, Nov 09 2007 03:41 PM
3 replies to this topic
#1
Posted 09 November 2007 - 03:41 PM
|
|
|
#2
Posted 10 November 2007 - 03:14 AM
int IsLeapYear(int iYear)
{
if(iYear % 400 == 0) return 1;
else if(iYear % 100 == 0) return 0;
else if(iYear % 4 == 0) return 1;
else return 0;
}
#3
Posted 10 November 2007 - 04:06 PM
A sentinel is a predefined value (usually one that cannot possible be correct input for the program) that is used to exit a loop. Basically:
read value;
while(value != sentinel) {
do calculation;
read value;
}
#4
Posted 10 November 2007 - 05:26 PM
Thanks for the reply
Now i have to add to this program to calculate the days between two dates. I will post my code later once i finish it. probably gonna need some help.
Now i have to add to this program to calculate the days between two dates. I will post my code later once i finish it. probably gonna need some help.


Sign In
Create Account

Back to top









