Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Saturday, July 16, 2022

C program to check whether the input year is a leap year or not for SEE and NEB


C program to check whether the input year is a leap year or not for SEE and NEB





Introduction:


A leap year is one with 366 days instead of the usual 365. Except for years that are divisible by 100 but not by 400, a leap year occurs every four years. For example, leap years include 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, and 2036.

In this article, we'll look at how to write a C program to check whether the input year is a leap year or not for SEE and NEB. The program will take the user's year as input and then print whether or not the year is a leap year.



Coding:


#include<stdio.h>
#include<conio.h>

main()

{

int year;

printf("Enter year=");

scanf("%d",&year);

if(year%400==0||year%100!=0&&year%4==0)

printf("Leap year");

else

printf("Not a leap year=");

getch();

}

Explanation of the program:

The program begins by asking the user for the year. Then it checks to see if the year is divisible by four. If the year is divisible by 4, the program checks to see if it is also divisible by 100. If the year is divisible by 100, the program checks to see if it is also divisible by 400. If the year is divisible by 400, the program indicates that it is a leap year. Otherwise, the program displays the fact that the year is not a leap year.

Output:




Conclusion:

Finally, using the C program provided in this article, you can write a C program to check whether the input year is a leap year or not for SEE and NEB. Understanding leap years and being able to accurately check them is critical for various date-related calculations in C programming. You can improve your skills for exams like SEE and NEB by incorporating this knowledge.


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages