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 :: format bool c 
C :: check if the c code is a palindrome 
C :: hi servicenow 
C :: c program to add two numbers 
C :: how to print value of pointer in c 
C :: ROUNDING decimal number in C 
C :: how to open a website in c 
C :: c programing strtok use 
C :: insertion sort c 
C :: read string with space c 
C :: c realloc 
C :: limit axis in one direction plt 
C :: space x 
C :: c sleep milliseconds 
C :: array size in c 
C :: Bitwise Operators in C/C++ 
C :: how i send custom data in model field rest_framework serializer 
C :: server client tcp in C 
C :: solana-test-validator log 
C :: variables in c 
C :: what is c 
C :: c print characters 
C :: . Simulate MVT and MFT. 
C :: arduino empty serial buffer 
C :: string in c and how it works 
C :: C special character display 
C :: boolean operators in c++ 
C :: insse suprafata arabila pe ani 
C :: Command to compile and execute a c file program consecutively 
C :: C Keyword typedef 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =