Answer to Question #284484 in C for shruthi

Question #284484

Write a program to print the number of leap years in the given list of years.



1
Expert's answer
2022-01-03T09:05:50-0500






#include <stdio.h>
#include <string.h>
#include <ctype.h>


int isLeapYear(int year){
	if (year % 4 == 0) {
		if (year % 100 == 0) {
			if (year % 400 == 0){
				return 1;
			}
		}
		else{
			return 1;
		}
	}
	return 0;
}


int main(){
	int n,i,year;
	printf("Enter n: ");
	scanf("%d",&n);


	for(i=0;i<n;i++){
		printf("Enter year %d: ",(i+1));
		scanf("%d",&year);
		if(isLeapYear(year)==1){
			printf("Year is leap\n");
		}else{
			printf("Year is NOT leap\n");
		}
	}






	getchar();
	getchar();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS