C PROGRAM TO FIND LEAP YEAR |LEAP YEAR|

 C program to find leap year or not


Code:

#include<stdio.h>
int main()
{
int year;
printf("enter the year:");
scanf("%d",&year);
if((year % 400==0)&&(!year % 100==0)||(year % 4==0))
{
      printf("year %d is a leap year",year);
}
return 0;
}


Explanation:

  • The user enter the year.
  • The user entered year is stored in variable called "year" which is a integer datatype.
  • We had used if statement to check whether the entered year is leap year or not.
  • In if condition year%400=0 and ! year%100==0 or year%4=0 will be true only if both conditions are stratified.
  • If the condition is true then it will print the year is leap year .
  • If the condition is false then the printf statement won't be printed.
  • It will come out of the condition.

Output:






Comments

Popular posts from this blog

Use of Backslash "\n" in C language

COHESION AND COUPLING material

Coding and Testing in software engineering