Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

check leap year or not and all century years are not leap years

+1 vote
asked Jul 24, 2018 by anonymous
Write a program to check whether given year is leap year or not

note-that all century years or not leap years

example-1900

for example-input 2000   - yes

3 Answers

0 votes
answered Jul 24, 2018 by someone to help
#include <iostream>

using namespace std;

int main()

{

 int year;

cout<<"enter the year:";

cin>>year;

if( year%100==0)

 {

   if (year%400==0)

cout<<"leap year\n";

  else

    cout<<"not a leap year\n";

 }

else if(year%4==0)

   cout<<"leap year\n";

 else

      cout<<"not a leap year\n";

 return 0;

}
0 votes
answered Jul 24, 2018 by Akhila Mekapothula (460 points)
#include<stdio.h>
main()
{
    int year;
    printf("enter year\n");
    scanf("%d",&year);
    if((year%4==0)&&(year%100!=0)||(year%400==0))
    printf("leap year");
    else
    {
        printf("not leap year");
    }

}
0 votes
answered Sep 4, 2018 by TechnicalSeek

#include<stdio.h>
int main()
{
int year;
printf("Enter the year you want to check\n");
//take a user input
scanf("%d",&year);
//check leap year.
if(year%400==0)
{
printf("%d is leap year\n",year);
}
else if(year%100==0)
{
printf("%d is not a leap year\n",year);
}
else if(year%4==0)
{
printf("%d is a leap year\n",year);
}
else
{
printf("%d is not a leap year\n",year);
}
}

Leap year program

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...