Home / Programs / Command Line Program to check if a year is Leap Year or Not
Programming Example

Command Line Program to check if a year is Leap Year or Not

👁 808 Views
💻 Practical Program
📘 Step by Step Learning
Command Line Program to check if a year is Leap Year or Not

Program Code

#include<stdio.h>
void main(int argc,char *argv[])
{
	int n;
	n=atoi(argv[1]);
	if(n%4==0)
	{
		if(n%100==0)
		{
			if(n%400==0)
			
				printf("Leap Year");
				else
				printf("Not Leap Year");
		}
		else
		printf("Leap Year");
   }
    else
    printf("Not Leap Year");
	getch();	
	
}

Output

2020

Leap Year

Explanation

Nope

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.