Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! π πΉLearn advanced coding techniques in C& C++ πΉMaster Linux internals & shell scripting πΉDeep dive into Data Structures & Algorithms πΉExplore Embedded Systems & Microcontrollers (8051,UART, RTOS) πΉGet hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
C Program to Check Leap Year
✅ C Program to Check Leap Year
#include <stdio.h>
int main()
{
int year;
printf("Enter a year: ");
scanf("%d", &year);
if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
printf("%d is a Leap Year\n", year);
else
printf("%d is NOT a Leap Year\n", year);
return 0;
}
π Explanation:
This C program checks whether a given year is a leap year or not.
A year is a leap year if:
- It is divisible by 400, OR
- It is divisible by 4 but not divisible by 100
These conditions are checked using logical operators and modulus (%) operator.
π§Ύ Sample Output:
Enter a year: 2024 2024 is a Leap Year
π Keywords:
C leap year program, leap year logic in C, C conditional statements, C if else program, year checking in C
π Search Description:
Learn how to check whether a given year is a leap year in C programming with simple logic, explanation, and output.
π Hashtags:
#CProgramming #LeapYear #CPrograms #ProgrammingBasics #1printf
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment