Search
 
SCRIPT & CODE EXAMPLE
 

C

c Program to check if a given year is leap year

// C program to check if a given
// year is leap year or not
#include <stdio.h>
#include <stdbool.h>
 
bool checkYear(int year)
{
    // If a year is multiple of 400,
    // then it is a leap year
    if (year % 400 == 0)
        return true;
 
    // Else If a year is multiple of 100,
    // then it is not a leap year
    if (year % 100 == 0)
        return false;
 
    // Else If a year is multiple of 4,
    // then it is a leap year
    if (year % 4 == 0)
        return true;
    return false;
}
 
// driver code
int main()
{
    int year = 2000;
 
    checkYear(year)? printf("Leap Year"):
                   printf("Not a Leap Year");
    return 0;
}
Comment

leap year in c

#include <stdio.h>
void
main ()
{
  int year;
  printf ("
 enter year to be checked for leap");
  scanf ("%d", &year);

  if (year % 4 == 0)
    {
      printf ("
 %d is leap year yay!", year);
    }
  else
    {
      printf ("
 year enterd is not leap, waaa :-(");
    }
}
Comment

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;
}
Comment

PREVIOUS NEXT
Code Example
C :: pop and push shows black screen which needs to be pressed back flutter 
C :: function component with props 
C :: maximo comun divisor 
C :: macos prevent disk mounting 
C :: sockaddr_in c 
C :: ecrire programme en C une fonction remplir tableau et un fonction inverser 
C :: how to select numeric columns in r 
C :: Turn on the first n Bits in number 
C :: mediawiki upload size 
C :: Command to create a static library in C 
C :: create arrya of chars malloc 
C :: insert image material ui 
C :: compile multiple c files 
C :: what is the use of malloc in c 
C :: c function definition 
C :: Install valet-linux 
C :: create syscall 
C :: string to number in c 
C :: how to print chicken in c 
C :: dev c online 
C :: create a gtk window 
C :: uninstall elgg from hostgtor 
C :: C Program to Maintain an Inventory of items in Online Store 
C :: asasz 
C :: c "hello world" 
C :: c byte vs char 
C :: wap in c to input n numbers in an array, find out the sum of odd nos. and even nos. display the numbers whose sum is high. 
C :: using tables as arguments in c++/c 
C :: how to compress image in c 
C :: snprintf with malloc 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =