Write a C C++ program to check leap year

 

Flowchart

Finding given year is leap or not flowchart

 

Coding in C

#include<stdio.h>
int main()
{
int y;
printf(“Enter an year: “);
scanf(“%d”,&y);
if(y%4==0&&y%100!=0||y%400==0)
{
printf(“Leap year”);
}
else
{
printf(“Not a leap year”);
}
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
int y;
cout<<“Enter an year: “;
cin>>y;
if(y%4==0&&y%100!=0||y%400==0)
{
cout<<“Leap year”;
}
else
{
cout<<“Not a leap year”;
}
return 0;
}

 

Output

Finding given year is leap or not output

 

Published by

admin

I am a computer teacher, programmer and web developer