How to check leap year or not in C programming

Check Leap Year or Not

 



#include<stdio.h> int main() { int a; printf("Enter the year which you want to check leap year or not\n"); scanf("%d", &a); if(a%4 == 0){ printf("The input year is a leap year\n"); }

if(a%400 == 0 ){

        if(a%100 == 0){

                printf("The entered number is not a leap year\n");

                } else{ printf("The entered number is a leap year\n");     }

    } else{ printf("The entered number is not a leap year\n"); } return 0; }

Now give the input and press Enter and check the result.

Here you can find we fixed the bug by dividing the number by 100. It is necessary for

correct coding.

Comments

Popular posts from this blog

Simple Rock Paper Scissors Game(Java)

Access denied in VS code for gcc while doing C programming

HackerRank 30 Days Of Code Challenge, Day8(Ques 9 in Java)