Write an algorithm for leap year in c.

Algorithm for leap year.

Algorithm

if(year%4==0 && year%100!=0) {
	printf ("Leap year");
}
else {
	if(year%400==0) {
		printf("Leap year");
	}
	else {
		printf("Not Leap year");
	}
}

Input from user

#include<stdio.h>
void main() {
	int year;
    
	printf("Enter a Year\n");
	scanf("%d", &year);

	if(year%4==0 && year%100!=0) {
		printf("Leap year");
	}
	else {
		if(year%400==0) {
			printf("Leap year");
		}
		else {
			printf("Not Leap year");
		}
	}
}

kabeer

Added  Jun 22, 10:58 am

×
Google login
SignUp with Email
X