Answer to Question #284478 in C for shruthi

Question #284478

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



Input:



First line of input is total number of years (n)



Next n lines will be the years.

1
Expert's answer
2022-01-04T01:10:21-0500
#define MAX_YEARS 100
// Return if year is leap year or not. 
bool isLeap(int y) 
{ 
    if (y%100 != 0 && y%4 == 0 || y %400 == 0) 
        return true; 
    return false; 
} 


main(void)
{
	int x,r,n,Years[MAX_YEARS],l=0;
	
	printf("\n\tEnter no. of years: "); scanf("%d",&n);
	for(r=0;r<n;r++)
	{
		printf("\n\tEnter Year-%d: ",r+1); scanf("%d",&Years[r]);
		if(isLeap(Years[r])) {l=l+1; printf("\t\tYear %d is a leap year.",Years[r]);}
	}
	printf("\n\n\Total no. of leap years = %d",l);


}

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