Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language function programming for judging leap year
C language function programming for judging leap year
1. First, we click Start in the lower left corner of the desktop to open the Visual C++ 6.0 software.

2. Then we build an empty project, and then an empty C source file.

3. The library function scanf () is mainly used here, and the calling format is scanf ("%d ",&; n); N is a defined integer variable. Sender &; Don't forget to write semicolons or something.

4. If the year can be divisible by 100, continue to judge. If it is divisible by 400, that year is a leap year, otherwise it is not. For example, 1900 is not a leap year, and 2000 is a leap year. If the year is not divisible by 100, continue to judge. If it is divisible by 4, that year is a leap year, otherwise it is not. For example, 2002 is not a leap year, and 2004 is a leap year.

5, compile, component files, generate exe files to run. Click the two buttons on the toolbar (as shown) to run the program.

6. The year entered is 1992, which cannot be divisible by 100. The output leap year is in line with the actual situation and the program design is correct.

7. Enter 1900, which can be divisible by 100. The output is not a leap year, which is in line with reality.