C Program to Check Whether a Year is Leap Year or Not Using Conditional Operator ?
Q:- Write a C Program to Check Whether a Year is Leap Year or Not Using Conditional
Operators ?
Operators ?
Input
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int year;
clrscr();
printf("Enter a Year =");
scanf("%d",&year);
(year % 4==0)
? printf("%d is Leap Year.",year)
: printf("%d is not Leap Year.",year);
scanf("%d",&year);
(year % 4==0)
? printf("%d is Leap Year.",year)
: printf("%d is not Leap Year.",year);
getch();
}
Output
Enter a Year = 2016
2016 is Leap Year.
2016 is Leap Year.
Comments
Post a Comment