Answer to Question #323901 in C for kit

Question #323901
  1. Your task is to ask the user for a year and then call the isLeapYear function to check whether the year is a leap year or not.
1
Expert's answer
2022-04-05T09:30:22-0400
#include <stdio.h>

int isLeapYear( int year) {
    return (year%4 == 0) && (year%100 != 0 || year%400 == 0);
}

int main() {
    int year;

    printf("Enter a year ");
    scanf("%d", &year);

    if (isLeapYear(year)) {
        printf("The %d is a leap year", year);
    }
    else {
        printf("The %d is not a leap year", year);
    }
    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