Thursday, February 1, 2024

C Language - Conditional Control Statements - If Conditions - Write a program to check whether a given year is leap year or not.

 Control Statements (Conditional Control Statements)
If Conditions

Example 8: Write a program to check whether a given year is leap year or not.

#include <stdio.h>

#include <conio.h>

void main()

{

            int year,n;

            clrscr();

            printf("\nENTER A YEAR: ");

            scanf("%d",&year);

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

                        printf("\n%d IS A LEAP YEAR",year);

            else

                        printf("\n%d IS NOT A LEAP YEAR",year);

            getch();

}

 

 

No comments: