Explanation: This program accepts a year from the user and checks whether it is a leap year using the if-else statement.
#include <stdio.h> #include <conio.h> main() { int year; clrscr(); printf("Enter the Year : "); scanf("%d",&year); if(year % 4 == 0) { printf("\nThis is a Leap Year"); } else { printf("\nThis is Not a Leap Year"); } getch(); }
Output:
if-else statement.%) operator with the if-else statement.100 is 0, then the year is divisible by 100.
#include <stdio.h> #include <conio.h> main() { int year; clrscr(); printf("Enter the Year : "); scanf("%d",&year); if(year % 100 == 0) { printf("\nYear is Divisible by 100"); } else { printf("\nYear is Not Divisible by 100"); } getch(); }
100 using the modulus (%) operator. If the remainder is 0, it displays "Year is Divisible by 100"; otherwise, it displays "Year is Not Divisible by 100".