The Program in C that determines whether the year is Leap or Not Using && and ||is given below:
#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
return 0;
}
Output:
Enter a year: 2012
2012 is a leap year.
Pro-Tips💡
This program prompts the user to enter a year, then uses if-else statements and logical operators && and || to determine if the year is a leap year or not.
A leap year is a year that is divisible by 4, except for end-of-century years which must be divisible by 400.
This program checks if the year is divisible by 4, and if it is, then it checks if it is not divisible by 100 or if it is divisible by 400.
If any of the condition is true then it will output leap year else not a leap yea
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.