Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS101 / KCS201 Programming for Problem Solving - Using C Language


Lab Exercises


9. Write a program that tells whether a given year is a leap year or not.


/*
 File: Prgrm09.c
 Author: Aditya Saini
 Date: Sept 24, 2019
 Description: Program to find whether a given year is a leap year or not.
*/

#include <stdio.h>

int main (void)
{
               int year;

               //Input year.
               printf ("Input Year: ");
               scanf ("%d", &year);

               //Finding whether the given year is a leap year or not and output the result.
               if (year % 4 == 0)
               {
                              printf ("%d is a Leap Year.", year); 
               }
               else
               {
                              printf ("%d is not a Leap Year.", year);
               }

               return 0;
};

Output

Input Year: 2024
2024 is a Leap Year.



No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib