Total Pageviews

Saturday 29 June 2013

Write a program to check whether the year is leap year or not.

 Write a Code in main.m

#import <Foundation/Foundation.h>
@interface LeapYear :NSObject
{
    int yr;
}
-(void)display;
@end


@implementation LeapYear
-(void)display
{
    printf("Enter the year:");
    scanf("%d",&yr);

    if(yr%2==0 && yr%100!=0)
    {
            printf("Year is LEAP YEAR");
    }
    else
    {
            printf("Year is Not LEAP YEAER");
    }
}

@end
int main (int argc, const char * argv[])
{
   
    LeapYear *lyr=[[LeapYear alloc]init];
    [lyr display];
}

OUTPUT:-

Year is Leap Year


 
Year is not Leap Year

No comments:

Post a Comment