Ans 2.1 Write a C Program to Input year and find it is leap year or not 1
#include<stdio.h> int main() { int y; printf("Enter year:"); scanf("%d",&y); if(y%4==0) { printf("Year is Leap Year"); } else { printf("Year is NOT a Leap Year"); } return 0; }
Ans 2.2 Write a C Program to Input year and find it is leap year or not. 1
#include<stdio.h> int main() { int y; printf("Enter year:"); scanf("%d",&y); //1. If the year is divisible by 4 and not divisible by 100, or //2. If the year is divisible by 400. if((y%4==0 && y%100!=0)||(y%400==0)) { printf("Year is Leap Year"); } else { printf("Year is NOT a Leap Year"); } return 0; }