c++ program

Any year is input through the keyboard, write a program to determine whether its leap year or not.
2005
Nope, it isn't
2012
Yeah!
I wrote it on a cocktail napkin but when I tried to compile it the stupid thing jammed in my DVD drive.

Thanks a lot! :-(

mhadel: You have to try writing it yourself. We'll help you but we won't do your homework.
well,like the previous comment,you need to try to write something you're self..it is not that hard,first try to find out what exactly is a leap year,and then you can start putting theory into practice and write you're program...here is a link to wikipedia..the answer is right there between the rows.

http://en.wikipedia.org/wiki/Leap_year
Homework questions always make me lol. Especially the ones that don't ask us to write one, rather command us. How about, at the very least,
Write a program to determine whether it's leap year or not please.


I'd try to make a brainfuck like hamsterman (I'm very envious of his coding) if i had the time.
Any year is input through the keyboard, write a program to determine whether its leap year or not.

What is that? :0
--Homework for us?
--Command line?....yap..oh--srry
# include <iostream>

using namespace std;

int main ()
{
int year;

cout << "input year: ";
cin >> year;
if ( year % 4 == 0 )
cout << "\nYeah!" << endl;
else
cout << "\nNope, it isnt"<< endl;
return 0;
}

is that what you are looking for?
Sorry. Fails at year 100. But you're close.

FYI, the idea is NOT to do someones homework but rather to help them do it.
closed account (jLNv0pDG)
Years that are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400, in which case they are leap years.
The wikipedia link posted by Mihay07 even has pseudo code for that. Just translate it to C++.
Here:
(define (f n) (or (= (remainder n 400) 0) (and (= (remainder n 4) 0) (not (= (remainder n 100) 0)))))
Topic archived. No new replies allowed.