a little confuse o_0???

This is a discussion on a little confuse o_0??? within the C++ Programming forums, part of the General Programming Boards category; A year is a leap year if it is divisible by 4,however, if a year is divisible by 100, it ...

1. a little confuse o_0???

A year is a leap year if it is divisible by 4,however, if a year is divisible by 100, it must be divisible by 400 for it to be a leap year. Hence, 2000 is a leap year, but 1900 is not. Make a program that will input a value for year (int) and output whether it is a "Leap Year" or "Not a Leap Year".

please someone can help me with these???

2. http://en.wikipedia.org/wiki/Leap_year#Algorithm

Convert that to C/C++ code and post it here if it gives you trouble.

gg

3. waaaaaaaaaaa....

i still can't get it to work >_<

i cant understand modulo T_T

thnx a lot dude

--
Mats

5. if year modulo 400 is 0 then leap
else if year modulo 100 is 0 then no_leap
else if year modulo 4 is 0 then leap
else no_leap

6. if ((year modulo 4 is 0) and (year modulo 100 is not 0)) or (year modulo 400 is 0)
then leap
else no_leap

 Leap day

7. http://en.wikipedia.org/wiki/Modulo_operation

As you can see in the table there, the C/C++ modulo operator is &#37;

gg

8. Yes, so how would you make that into C++ code?

--
Mats

9. yeah i agree
im a newbie
so i cant really understand how to make it in C++ code

for example

the modulo of 4??

how would you encode it in C++ ?

please codeplug a little bit of understanding here

10. I would recommend a tutorial to get you up to speed on the basics on the language. Once you know the basics, converting the logic in post #5 is a breeze.

http://www.cprogramming.com/tutorial.html#c++tutorial

gg

11. main()
{ int year;

clrscr();

p("Enter a year: ");
s("&#37;d",&year);

if(year%4==0 && year%100==0 && year%400)
p("The year %d is a leap year.",year);
else
p("The year %d is not a leap year.",year);

i can't get the 1900 as not a leap year T_T

still having problems with it huhuhu

12. Compare your own post #5 with what you have actually implemented in your C-code.

And a word of advice: Don't "make your own language" - printf() is a stanard function, don't use #define p printf and #define s scanf - it's just so much harder to read.

--
Mats

13. This being the C++ forum, consider using cout and cin instead . . . or post your thread in the C forum next time.

Use code tags: [code] Code here [/code]
And try to post complete code.

Oh, and main() should return int. The implicit-int rule is deprecated.
Code:
```int main() {
/* ... */
return 0;
}```

14. hehehehe
sorry for that dude....
i just made that here since it is easy to write

T_T

thnx to all who replied....

Page 1 of 2 12 Last