a little confuse o_0???

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 01-23-2008
omarbags
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???

• 01-23-2008
Codeplug
http://en.wikipedia.org/wiki/Leap_year#Algorithm

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

gg
• 01-23-2008
omarbags
waaaaaaaaaaa....

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

i cant understand modulo T_T

thnx a lot dude
• 01-23-2008
matsp

--
Mats
• 01-23-2008
omarbags
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
• 01-23-2008
omarbags
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
• 01-23-2008
Codeplug
http://en.wikipedia.org/wiki/Modulo_operation

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

gg
• 01-23-2008
matsp
Yes, so how would you make that into C++ code?

--
Mats
• 01-23-2008
omarbags
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

• 01-23-2008
Codeplug
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
• 01-23-2008
dwks
• 01-23-2008
omarbags
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
• 01-23-2008
matsp
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
• 01-23-2008
dwks
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;
}

• 01-23-2008
omarbags
hehehehe
sorry for that dude....
i just made that here since it is easy to write

T_T

thnx to all who replied....
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last