1 0

Leap year program in C using if else

- Advertisement -
Read Time:1 Minute, 21 Second

Leap year program in C using if else.

before creating program it is important to know what is leap year? Generally, a year has 365 days, but a leap year has 366 days which comes after every 4 year. following are the points related to leap year.

1. A leap year is year. which is different from another year because it has one extra day in the month of February.

2. A leap year comes once in a four year. in which february month has 29 days instead of 28 days.  

3. Some example of leap year are 2004, 2008, 2012 and 2016.

 

Below condition are apply to check following year is leap or not.

1. Year must be divisible by 4.

2. Year is divisible by 400 and not divisible by 100.

 

By putting these condition in your C program you can easily find the year is leap or not leap. These condition can be put with help of if-else or with && (and) and ||(or).

Below are the C program to find whether the year is leap or not

 

Input:-

#include<stdio.h>

#include<conio.h>

void main()

{

int year;

clrscr();

printf(“enter the year:”);

scanf(“%d”,&year);

int temp=year/100;

if(year%100==0)

{

if(temp%4==0)

{

printf(“%d is leap year.”, year);

}

else

{

printf(“%d is ordinary year.”, year);

}

}

else

{

if(year%4==0)

{

printf(” %d is leap year.”, year);

}

else

{

printf(“%d is ordinary year.”, year);

}

}

getch();

}

Output:-

Leap year program in C using if else
Leap year program in C using if else

 

 

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
- Advertisement -

Follow US!

FansLike
FollowersFollow
FollowersFollow
SubscribersSubscribe

Latest Post

Introduction to Online Analytical Processing and Data Mart

Introduction to Online Analytical Processing and Data Mart

Introduction to Online Analytical Processing and Data Mart Online Analytical Processing OLAP is computer processing that enables a user to easily and selectively extract and view...
A data warehouse is a relational database that is designed for query and analysis rather than for transaction processing

Introduction to Data Warehouse

Introduction to Data Warehouse A data warehouse is a relational database that is designed for query and analysis rather than for transaction processing. It usually...
Introduction to Advance Database System

Introduction to Advance Database System

Introduction to Advance Database System ABSTRACT Data is collection of raw facts and figure which is basic for decision making. Anything which is unorganized is called...
What is Ternary Operator in C programming with example

What is Ternary Operator in C programming with example

What is Ternary Operator in C programming with example Ternary Operator In the C language ternary operator is allowing for executing or running any code based...
C program to check student is pass or fail using if else, nested if and ternary operator.

What is Conditional Statement in C programming

What is Conditional Statement in C programming Conditional Statement Conditional Statements in C programming are used to make decisions based on the different conditions. Conditional statements...
C programming if else statement

C programming if else statement

C programming if else statement Conditional Statements in C programming are used to make decisions based on the conditions. Conditional statements execute sequentially when there...