Search

Leap year program in C || C Programs

Code -

#include<stdio.h> 
#include<conio.h> 
void main() {  
 int year;  
    printf("Enter a year: ");  
    scanf("%d", &year);  
 if(((year%4==0) && ((year%400==0) || (year%100!==0))  
    {  
        printf("%d is a leap year", &year);  
    } else {  
        printf("%d is not a leap year", &year);  
    }  
    getch();  
}  

Output -

Enter a year: 2004
2004 is a leap year
3 views0 comments

Related Posts

See All

Program of Random Number in C || C Programs

Code - #include <stdio.h> #include <conio.h> #include <stdlib.h> void main() { // use rand() function to generate the number printf (" The random number is: %d", rand()); pri

Getchar() function in C || C Programs

Code - #include <stdio.h> #include <conio.h> void main() { char c; printf ("\n Enter a character \n"); c = getchar(); // get a single character printf(" You have passed ")

  • 1024px-Telegram_logo.svg
  • download
  • YouTube