Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Find Leap Year in C language using Nested If statements

In this post, I am going to write a C program with Nested if statements to find the Leap year.

This example C program is very much useful for school students and for the beginners.

// include the header files
#include 
#include 

void main() {
	
  int x;
  printf("Enter a year:");
  scanf("%d", & x);
  
  // nested if statements to check Leap year 
  if (x % 4 == 0) {
    if (x % 100 == 0) {
      if (x % 400 == 0) {
        printf("%d is a leap year", x);
        exit(0);
      } else {
        printf("%d is not a leap year", x);
        exit(0);
      }
    } else {
      printf("%d is a leap year", x);
    }
  } else {
    printf("%d is not a leap year", x);
  }

}

I believe this post would have helped you to understand how to write a nested If statement in C language and also how to find leap year.

The post Find Leap Year in C language using Nested If statements appeared first on Tutorials Made.



This post first appeared on TutorialsMade - Ultimate Tutorial, please read the originial post: here

Share the post

Find Leap Year in C language using Nested If statements

×

Subscribe to Tutorialsmade - Ultimate Tutorial

Get updates delivered right to your inbox!

Thank you for your subscription

×