leap year in c

#include <stdio.h>
int main() {
   int year;
   printf("Enter a year: ");
   scanf("%d", &year);

   // leap year if perfectly visible by 400
   if (year % 400 == 0) {
      printf("%d is a leap year.", year);
   }
   // not a leap year if visible by 100
   // but not divisible by 400
   else if (year % 100 == 0) {
      printf("%d is not a leap year.", year);
   }
   // leap year if not divisible by 100
   // but divisible by 4
   else if (year % 4 == 0) {
      printf("%d is a leap year.", year);
   }
   // all other years are not leap year
   else {
      printf("%d is not a leap year.", year);
   }

   return 0;
}

4.5
2
Kwonpark 90 points

                                    #include &lt;stdio.h&gt;
int main() {
   int year;
   printf(&quot;Enter a year: &quot;);
   scanf(&quot;%d&quot;, &amp;year);

   // leap year if perfectly divisible by 400
   if (year % 400 == 0) {
      printf(&quot;%d is a leap year.&quot;, year);
   }
   // not a leap year if divisible by 100
   // but not divisible by 400
   else if (year % 100 == 0) {
      printf(&quot;%d is not a leap year.&quot;, year);
   }
   // leap year if not divisible by 100
   // but divisible by 4
   else if (year % 4 == 0) {
      printf(&quot;%d is a leap year.&quot;, year);
   }
   // all other years are not leap years
   else {
      printf(&quot;%d is not a leap year.&quot;, year);
   }

   return 0;
}

4.5 (2 Votes)
0
3.5
2
I.tawfik 85 points

                                    #include &lt;stdio.h&gt;
int main() 
{
int year;
printf(&quot;Enter the year&quot;);
scanf(&quot;%d&quot;, &amp;year);
if (year % 400 == 0) 
{
printf(&quot;%d is a leap year&quot;, year);
}
else if (year % 100 == 0) 
{
printf(&quot;%d is not leap year&quot;, year);
}
else if (year % 4 == 0)
{
printf(&quot;%d is a leap year&quot;, year);
}
else
{
printf(&quot;%d is not leap year&quot;, year);
}
return 0;
}

3.5 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
leap year using if else in c check whatever leap year in c leap year check c see if a year was a leap year c leap year c code c program to find whether a given year is leap year or not how to check for the leap years c leap year calculator in c write a program to check leap year in c condition of leap year in c Find a year is leap year or not in c Write a C program to check whether a year is leap year or not leap year testing logic for c calculate leap year in c by using switch case a year leap year or not write a c program by switch case a year leap year or not write a c programe leap year condition in c c program to check if leap year or not How to determine whether a year is a leap year c checking leap year in c logic for leap year or not in c logic leap year or not in c Write down C program to check given year is leap year or not. leap year examples in c how to find leap year in c leap year using c formula for determining leap year in c check year is leap year in c condition for leap year in c leap year concept in c code for leap year in c leap year program logic in c how to find a year is a leap year in c how to find a year is leap year or not in c leap year for loop in c leap year in loop in c leapyear in c leap year check c program how to check year is leap year or not in c check if year is leap in c leap year using duction in c to check leap year in c leap year calculation c leap year calculation in c leap year algorithm in c c program To Find leap year or not . write a c program to find leap year using conditional operator leap year program c leap year or not in c Write a C program that accepts a year and finds whether year entered is a leap year or not. leap year c program for checking leap year in c leap year in c programming leap year finder c algorithm for leap year program in c calculate leap year in c how to calculate leap year in c logic of leap year in c c leap year program c code for leap year concept of leap year in c c leap year calculation c program leap year what is a leap year c how to check a year is leap year in c how to find leap years in c logic for a leap year in c C leapyear function leap year or not c check leap year using function in c leap year program in c using logical operators how to find out leap year in c c program to find leap year opf not a c programme to cheek leap year leap year by c leap year formula in c leap year logic if else in c leap year coding nleap C leap year logic in c 12. C Program to check leap year. c program to check whether a number is leap year or not c program to find leap year write a c program to check leap year or not a c program to check leap year code for leap year lleap year in c how to count leap year in c leapyear login leap year finding c program c programming language leapYear code leap year c programing Write a c program to check whether a year is leap year or not. c program for leap year WAP to find whether a year is leap year or not. how to calculate leap year c program leap year code in c using while loop loop the years and check leap year or not in c Check the given year is leap year or not in c fid the number of leap years in c algorithm for leap year or not leap year logic leap year code leap yerar in c 10.Write a C program to check whether a year is leap year or not. find leap year in c how to find leap year using c program leap years in c Write a program to check leap year check leap year or not Write a C program to find the year entered year is Leap Year or not. check leap year in c leap year in c concept of leap year in programming leap year program Program to check whether a year is a Leap Year or not program to find leap year is leap year code in c program to check whether it is leap year or not program to check if a year is leap year or not code to determine leap year How to calculate a leap year progr program for leap year leap year code in c leap year program in c code to check for leap year c program to check leap year finding leap year program check if leap yer or not in c find if a year is leap or not in c leap year or not program in c Write a program to check if a year given by user is leap year or not. leap year c program
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source