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);
@carl5720
2 жыл бұрын
Sir how to put trivia on each year?
@mdhamid7118
2 жыл бұрын
Very short code but But only leap year execute other year not any return
@praveennaik7059
2 жыл бұрын
@@mdhamid7118 You should add else condition for that
@sharkopyt2208
2 жыл бұрын
For 2012?
@Karthikgupta-r2w
Ай бұрын
What if the no is not a leap year? What will user understand
@verandi3882
Жыл бұрын
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.
@vaibhuuanand
6 жыл бұрын
Please upload some videos for 'Design and Analysis of Algorithms(DAA)'.
@aayushchoudhary-p7d
9 ай бұрын
Thanks for clearing the concept of leap year sir .
@shubhambhattacharya1618
6 жыл бұрын
What is the use of checking the year divisible by 100?
@kasyapkocharlakota6520
4 жыл бұрын
Shubham Bhattacharya same doubt and why should we check with 400 all numbers which are divisible by 400 are also divisible by4
@aravindks7636
4 жыл бұрын
Bro, it's a simple logic centurial year is occurring during 100 years so every year after 400 years also a leap year.. 4*100.. note that point take the and condition divisible by both 100 and 400
@ritikshrivastava9442
4 жыл бұрын
#include int main() { int year; printf("enter the year "); scanf("%d",&year); if ( year % 4 == 0) { printf("this is the leap year "); } else { printf("this is not the leap year"); } } This code also works perfectly fine
@SonuGupta-wj6dg
3 жыл бұрын
@@ritikshrivastava9442 check out 1900
@afikonyak5046
2 жыл бұрын
@@ritikshrivastava9442 i did the same before reading this comment! I did not add ==0 in the if expression but now thanks to you it's working
@harshavardhan184
2 жыл бұрын
*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! 😊
@muhammadaliyumaraliev4933
3 жыл бұрын
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?
@harshkathpal5806
3 жыл бұрын
2100 %4 ==0 but not leap year
@leelavathidevi8371
4 ай бұрын
super fantastic mind-blowing explanation sir
@ThePravya
5 жыл бұрын
sir for year 1900 you have shown the calendar of year 1990
@prog2597
4 жыл бұрын
Yes
@kushal_Yt
4 жыл бұрын
i noticed that too :-))
@ashok-bk6pv
4 жыл бұрын
@@kushal_Yt even i too!
@harshavardhan184
2 жыл бұрын
Yup
@itsbayahmed
Жыл бұрын
This is another solution to this exercise: #include 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); }
@teacoffee8255
3 жыл бұрын
I can clearly understand 😍🤩woowww keep it up superb
@TheAnkitNainwal
3 жыл бұрын
Why there are 3 conditions if we van get leap year by simply dividing by 4 ??
@prog2597
4 жыл бұрын
1900 is also a leap year as it is divisible by 4
@kushal_Yt
4 жыл бұрын
but its centurial year and not divisible by 400 !
@tayyab.sheikh
8 ай бұрын
But what about the calendar, it has 28 days in it.
@hasleyindiahasley9718
6 жыл бұрын
Thanku sir .. Plz help in python
@harshkathpal5806
3 жыл бұрын
def is_leap(year): leap = False if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0): leap = True return leap year = int(input()) print(is_leap(year))
@rajeshmudavath3769
3 жыл бұрын
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
@gauravrajpurohit882
2 жыл бұрын
yes i noticed that
@tahayasmin6070
2 жыл бұрын
Thank you sir🙂
@avinashchourasiya3463
5 жыл бұрын
your input is 1900 and showing calendar of 1990. Although 1990 is leap year
@EverythingTechWithMustafa
5 жыл бұрын
Century year leap year nahi hota
@prog2597
4 жыл бұрын
@@EverythingTechWithMustafa nope after checking the divisibility of 4 and 400
@prog2597
4 жыл бұрын
But 1990 is not a leap year, not divisible by 4 and 400
@thebrg
3 жыл бұрын
Your Videos are Awesome.🇳🇵🇳🇵
@ehabtalaat7592
6 жыл бұрын
thank u make more videos every day about c program and your videos are amazing
@MsLetishia
8 ай бұрын
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 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 ", y); else printf("%d is not a leap year ", y); return 0;
@vijaya4870
2 жыл бұрын
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 😊
@mohammaddawoodomidi2169
3 жыл бұрын
Why do we need 100, can't we say if it's divisible by 4, then it's leap year otherwise, it's not?
@patalamrithish6838
2 жыл бұрын
No bro long time I too have same doubt.... Century years like 1000,1100,1200...2000 all are divisible by 4 but in that only 400 divisible are leap years... remaining middle years just divisible by 4 is enough.. I hope your doubt are cleared
@goutamghosh8809
3 жыл бұрын
Which app is used for the execution? Can you please tell me sir
@pravinkakade8810
3 жыл бұрын
codeblock....... download and install...... watch initial some video
@goutamghosh8809
3 жыл бұрын
@@pravinkakade8810 Thank you very much 😃 I have already searched this and got the app. It's a great app really 😃
@abhishekhugar212
3 жыл бұрын
Better to use dev c app It is simple and efficient In code blocks u will get more option and it's bit complex compared to dev c app
@goutamghosh8809
3 жыл бұрын
Yes I have heard about the Dev C app. I will surely try on it also. Currently I am using Coding C, that is an excellent one, I got it while searching for codeblocks. Thank you for your valuable suggestion😊 Stay safe.
@mohammedisarezwani
10 ай бұрын
i solved this problem myself with over 20 lines 😂 my solution is so confusing and different form yours
@4olufade
29 күн бұрын
If 1896 and 1904 were leap year, then 1900 was a leap year. the only test should be if(year % 4)
@carl5720
2 жыл бұрын
Sir how to put trivia on each year?
@dambro3312
Жыл бұрын
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);
@mothukuriomsaiprakash2999
4 жыл бұрын
what about 200 it is divisible by 100 and 4
@mehadihasansanto538
4 жыл бұрын
At first the if condition will be checked. Then the else if will be checked which is containing (year % 100 == 0). Then the next one which is containing (year % 4 == 0). Then the else will come which is a default condition. But here u have to remember that if one of the conditions is satisfied then the rest of the conditions won't be checked & executed. That's why when u input 200, at first it will be checked by the if condion, but 200 is not divisible by 400 so that it will be checked by the next condition i.e. 1st else if. And now 200 is divisible by 100. So, the rest of the condition won't be checked. Hence, output will be - Not a leap year.
@tanushree4088
3 жыл бұрын
Please tell y 400%and 100% is used here
@pritisharaychaudhuri7599
3 жыл бұрын
% is modulus division. It actually gives you the remainder. 400 is used for centurial years, if a centurial year is a leap year then it should be divisible by 400 or by 100 and 4. 100 again is used for centurial years, if a cnturial year is only divisible by 100 and not by 4 and 400 it is not a leap year,
@sukhbeersingh5811
3 жыл бұрын
#include int main() { int year; printf ("Enter the year"); scanf ("%d",&year); if (year%4==0) printf ("%d is a leap year ",year); else printf ("%d is not a leap year",year); return 0; } Sir this code is also working for leap year 🙄 please have a check and if any mistake is there please let me know btw thank you for your awesome lecture ❤️👍.
@camerald8257
3 жыл бұрын
Not an expert, but I believe that if it is checking for any years that is only divisible by 4, it will say it is divisible by 4 then its leap year but the same can be said to the centurial year, they can also be divisible by 4 meaning they can be a leap year but not all centurial year are leap years they should be divisibe by 4 and 400 for them to be a leap year.
@gurusamyd9531
3 жыл бұрын
If(year%==0) sir why we put ==0
@koustavbetal
2 жыл бұрын
Hey and what about 1800. This is devisable to 4 so does that mean it's a leap year ?? Nope..
@krutarthpatel6537
3 жыл бұрын
👌
@ritikshrivastava9442
4 жыл бұрын
#include int main() { int year; printf("enter the year "); scanf("%d",&year); if ( year % 4 == 0) { printf("this is the leap year "); } else { printf("this is not the leap year"); } } Use this and check year it will work perfectly fine
@vamshisurya2991
3 жыл бұрын
completely wrong
@harshkathpal5806
3 жыл бұрын
2100 %4 ==0 but not leap year
@kaushikigoel759
5 жыл бұрын
Can anyone help me with my code blocks... Programs are correct and they get build also.. But when I run it.. No output shows and it says "process terminated with status -1073741510".. If anyone can help me out.. I'll be very greatful.. As I have searched a lot on goggle but found Nothing!! Hope for a positive response😶!
@harshitvarikolu8752
5 жыл бұрын
use atom, much better than codeblocks.
@PankajKP
6 жыл бұрын
1 st view 1st like 1st comment
@anandkumar-bd2ru
2 жыл бұрын
if(year %100==10) { if (year%400 ==0) leap year } else if (year %4) ==0 leap year
@omgaikwad0510
3 жыл бұрын
No need of 3 conditions. If a year is divisible either by 400 or 4 then its a leap year else its not a leap year. Simple ....
@ankitaman7890
3 жыл бұрын
You are using "or" operator here but the catch is we have to solve it only with the if,elseif and else condition.
@omgaikwad0510
3 жыл бұрын
@@ankitaman7890 Ok
@shreya5382
17 күн бұрын
Then it would show 1900 as leap year as it is divisible by 4 but actually 1900 is not a leap yr. Not everything is that 'simple'. Don't be overconfident.
@SKashyap3
8 ай бұрын
you didnot explain clearly.
@yaswanths5382
2 жыл бұрын
Sir did you got cold while you teaching this session 🙂🙂😂
Пікірлер: 83