Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
17K views

C Program To Check Leap Year

This document discusses a program logic for determining if a year is a leap year or not. The program logic states that a year is a leap year if it is divisible by 4, unless it is also divisible by 100, in which case it is not a leap year, except if it is divisible by 400, then it is a leap year. The document then provides an example C program that takes a year input and prints whether it is a leap year or not based on this logic.

Uploaded by

Saiyasodharan
Copyright
© Public Domain
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
17K views

C Program To Check Leap Year

This document discusses a program logic for determining if a year is a leap year or not. The program logic states that a year is a leap year if it is divisible by 4, unless it is also divisible by 100, in which case it is not a leap year, except if it is divisible by 400, then it is a leap year. The document then provides an example C program that takes a year input and prints whether it is a leap year or not based on this logic.

Uploaded by

Saiyasodharan
Copyright
© Public Domain
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

LEAP YEAR OR NOT

Program Logic: If the year is divisible by 4, it is a leap year. But, if it is divisible by 100, it is not. If the year is divisible by 400, it is a leap year. Examples: 1. 1996 is a leap year. (divisible by 4) 3. 2100 is a not leap year. (divisible by 100) 2. 2000 is a leap year. (divisible by 100 but also divisible by 400) Program: #include<stdio.h> #include<conio.h> void main() { int year; clrscr(); printf("Enter a Year to check : "); scanf("%d", &year); if(year % 400 == 0) printf("%d is a Leap Year.", year); else if(year % 100 == 0) printf("%d is not a Leap Year.", year); else if(year % 4 == 0) printf("%d is a Leap Year.", year); else printf("%d is not a Leap Year", year); printf("\nPress any key to Quit..."); getch(); } More useful programs @ http://www.gethugames.in/blog/

You might also like