Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Leap year using function in c

#include<stdio.h>

int isLeapYear(int n);

int main(void) {
    // TODO: Write your code here
  
  int n, x;
  
  printf("Enter year: ");
   scanf("%d", &n);
  
  if(isLeapYear(n)){
		printf("%d is a leap year",n);
	}else{
		printf("%d is not a leap year",n);
	}
  
    return 0;
}

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

    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Leap #year #function
ADD COMMENT
Topic
Name
5+9 =