Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

10 Mar 2013

C PROGRAM TO CHECK WHETHER GIVEN YEAR IS LEAP YEAR OR NOT


C PROGRAM TO CHECK WHETHER GIVEN YEAR IS LEAP YEAR OR NOT

#include<stdio.h>
void LeapYear(int);
void main()
{
    int year;
    printf("\n *** C PROGRAMS BLOG *** \n");
    printf("\n >>>> C PROGRAM TO CHECK WHETHER GIVEN YEAR LEAP YEAR OR NOT <<<< \n");
    printf("\n Enter the year : ");
    scanf("%d",&year);
    LeapYear(year);
    getch();
    return 0;
}
void LeapYear(int yr)
{
    int rem1,rem2;
    rem1 = yr%4 ; //rem1 = 0 for leap year
    rem2 = yr%100; //rem2! = 0 for leap year
    if((rem1 == 0) && (rem2!=0) || yr%400 == 0)
    {
        printf("\n The given year %d is Leap Year..",yr);
    }
    else
    {
        printf("\n The given year %d is Not Leap Year..",yr);
    }
    
}

Sample Output :



3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. C tutorial with free and simple example on Data Types & Variables, Conditionals, Loops, Arrays & Strings etc. Here you can download simple and easy online c tutorial for beginners .C Programming online test.

    ReplyDelete
  3. Good
    Here is a link for C/C++ programs and pointer programs. This may be useful for you.

    C/C++ Programs

    ReplyDelete