Wednesday 18 July 2012

Conditional statement013

Any year is entered through the keyboard, write a program to determine whether the year is leap year or not.   Use the logical operators && and ||. 

#include <stdio.h>

#include <conio.h>

void main( )
{
        int         y;
        clrscr ( );
        
        printf ("\n Enter year............:"); scanf ("%d",&y);

        if ( y % 400 == 0 || y % 100 != 0 && y % 4 == 0 )
                      printf ("\n LEAP YEAR");
        else      
                      printf ("\n NOT LEAP YEAR");
        getch ( );
}

To contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...