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 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();	
	
}
                        

🖥 Program Output

2020

Leap Year
                            

📘 Explanation

Nope
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.