program to check leap year or not in c-programming.
In this program, user will enter the values and check weather the year is leap year or not .
It is not true to say that If a year is divisible by 4 then it is a leap year and it is not divisible by 4 then it is not a leap year.
A year is a leap year if and only if :-
.It is first divisible by 100 ,then it should also be divisible by 400.
. except this , if the year is divisible by is 4 then it is leap year.
lets us write this logic in c-program. To understand this program in c-programming.
#include<stdio.h>
#include<conio.h>
void main()
{
int year;
printf("enter the number\n");
scanf("%d",&year);
if(year%100==0){
if(year%400==0)
printf("leap year");
else
printf("not a leap year");
}
else{
if(year%4==0)
printf("leap year");
else
printf("not a leap year");
}
getch();
}
output:
enter the values of the year a= 200
200 is a leap year.For more c-programming :-
No comments:
Post a Comment