in pascal, if i wanna classify something into different category and count how many items i have in each category, how would i do that?

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Duoas

What is it you wish to classify?

for instance, if i wanna check all years from 2000 to 2050 and show each leap year and how many leap years there are, how would i show how many leap years there are?

OK, that helps.

This is a purely mathematical question. You'll need a function to tell you if a given year is a leap year or not. It so happens that the Delphi VCL has a function that does just that: `uses SysUtils;` `function IsLeapYear( year: word ): boolean;` Now think about how you can use that function to check each year for a leap year, and count how many leap years you find.

Hint: get out the construction paper and crayons and do it there first. This helps me all the time because by first solving the problem without the computer I have a better idea of how to tell the computer how to solve the problem.

Once you get some code together, post back here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.