Special Programs in C − Check Leap Year

preview_player
Показать описание
C Programming & Data Structures: C Program to check if the given year is a leap year or not.
Topics discussed:
1) Basics of Leap year.
2) C program to check if the given year is a leap year or not.

Music:
Axol x Alex Skrindo - You [NCS Release]

#CProgrammingByNeso #CProgramming #LeapYearProgram
Рекомендации по теме
Комментарии
Автор

so basically, we have two types of possible years to deal with, normal years and centurial years, first we check whether it is centurial or not, so if it is divisible by 100 it is centurial AND ALSO divisible by 400 then that is a leap year, other wise not leap .
then if it is normal, then it is not centurial hence NOT divisible by 100, AND ALSO divisible by 4 then it is a leap year, other wise not.
so :
if (y%100==0 && y%400==0 || y%100!=0 && y%4==0)
thank you very much for explaining and givinig me a new way to see it, my professor i n college was useless and doesnt like to discuss a different approach to solving it.

verandi
Автор

Thanks for clearing the concept of leap year sir .

aayushchoudhary-pd
Автор

I can clearly understand 😍🤩woowww keep it up superb

teacoffee
Автор

Please upload some videos for 'Design and Analysis of Algorithms(DAA)'.

vaibhuuanand
Автор

super fantastic mind-blowing explanation sir

leelavathidevi
Автор

A simpler approach would be to check the year using the following condition:
if ( (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0) )
printf("%d is a leap year!", year);

yenzyhebron
Автор

What is the use of checking the year divisible by 100?

shubhambhattacharya
Автор

Sir good job but on the calendar 1990 shown but in the output 1900(which is I guess leap year) and why do we need for dividing 100 which is also divisible to 4? should not the code be like checking divisible for only 4 or not?

muhammadaliyumaraliev
Автор

i solved this problem myself with over 20 lines 😂
my solution is so confusing and different form yours

mohammedisarezwani
Автор

thank u make more videos every day about c program and your videos are amazing

ehabtalaat
Автор

I used this definition of a leap year to make a simple, singular condition. A leap year is a centurial year which is divisible by 400 OR a non- centurial year which is divisible by 4:
#include<stdio.h>

int main(){
int y;
printf("Enter a year:");
scanf("%d", &y);
/*centurial year divisible by 400 and non-centurial year divisible by 4*/
if((y % 400 == 0)||(y % 100 != 0 && y % 4 == 0))
printf("%d is a leap year\n", y);
else
printf("%d is not a leap year\n", y);
return 0;

MsLetishia
Автор

sir for year 1900 you have shown the calendar of year 1990

ThePravya
Автор

*An year is said to be Leap year if :-*
*** A non centurial year ( 2024, 2012, ..etc) is divisible by 4 is a leap year.
***A centurial year(2000, 4000..etc) which is divisible by 400 is a leap year
*** A centurial year which is not divisible by 400 but divisible by 100.( Ex:- 3000, 5000..etc)Is not a leap year.
Thank you..i got this clarity now! 😊

harshavardhan
Автор

1900 is also a leap year as it is divisible by 4

prog
Автор

Everything is good
But there is a small mistake in video
ie., At time 3:53/4:32 in video
Input in program is given as year 1900
But in picture it shows year 1990

rajeshmudavath
Автор

Why there are 3 conditions if we van get leap year by simply dividing by 4 ??

TheAnkitNainwal
Автор

Thank you so much sir
The way you explained helped us a lot
And gives a very clear idea to beginners also
Once again thank you so much sir 😊

vijaya
Автор

here inp is the input year!!
if ( !(inp%400) || ( !(inp%4) && inp%100 ) ) printf("%u is a leap year", inp);
else printf("%u is not a leap year", inp);

dambro
Автор

your input is 1900 and showing calendar of 1990. Although 1990 is leap year

avinashchourasiya
Автор

This is another solution to this exercise:

#include <stdio.h>
int main()
{
int year;

printf("Please Enter the year you want to check: ");
scanf("%d", &year);

if ((year % 400 == 0 && year % 100 == 0) || (year % 100 != 0 && year % 400 != 0 && year % 4 == 0))
printf("This is a Leap year");
else
printf("This is NOT a Leap year");
return (0);
}

bahmed_dev