Special Programs in C − Check Leap Year

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ม.ค. 2025

ความคิดเห็น • 84

  • @verandi3882
    @verandi3882 2 ปีที่แล้ว +2

    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.

  • @teacoffee8255
    @teacoffee8255 3 ปีที่แล้ว +4

    I can clearly understand 😍🤩woowww keep it up superb

  • @vaibhuuanand
    @vaibhuuanand 6 ปีที่แล้ว +8

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

  • @aayushchoudhary-p7d
    @aayushchoudhary-p7d ปีที่แล้ว

    Thanks for clearing the concept of leap year sir .

  • @shubhambhattacharya1618
    @shubhambhattacharya1618 6 ปีที่แล้ว +11

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

    • @kasyapkocharlakota6520
      @kasyapkocharlakota6520 4 ปีที่แล้ว +5

      Shubham Bhattacharya same doubt and why should we check with 400 all numbers which are divisible by 400 are also divisible by4

    • @aravindks7636
      @aravindks7636 4 ปีที่แล้ว +2

      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
      @ritikshrivastava9442 4 ปีที่แล้ว +8

      #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
      @SonuGupta-wj6dg 4 ปีที่แล้ว +3

      @@ritikshrivastava9442 check out 1900

    • @afikonyak5046
      @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

  • @yenzyhebron5278
    @yenzyhebron5278 3 ปีที่แล้ว +33

    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
      @carl5720 3 ปีที่แล้ว +1

      Sir how to put trivia on each year?

    • @mdhamid7118
      @mdhamid7118 2 ปีที่แล้ว +4

      Very short code but
      But only leap year execute other year not any return

    • @praveennaik7059
      @praveennaik7059 2 ปีที่แล้ว +5

      @@mdhamid7118 You should add else condition for that

    • @sharkopyt2208
      @sharkopyt2208 2 ปีที่แล้ว

      For 2012?

    • @Karthikgupta-r2w
      @Karthikgupta-r2w 4 หลายเดือนก่อน

      What if the no is not a leap year? What will user understand

  • @leelavathidevi8371
    @leelavathidevi8371 7 หลายเดือนก่อน

    super fantastic mind-blowing explanation sir

  • @muhammadaliyumaraliev4933
    @muhammadaliyumaraliev4933 4 ปีที่แล้ว +9

    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?

  • @TheAnkitNainwal
    @TheAnkitNainwal 3 ปีที่แล้ว +3

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

  • @ThePravya
    @ThePravya 5 ปีที่แล้ว +8

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

  • @tahayasmin6070
    @tahayasmin6070 2 ปีที่แล้ว

    Thank you sir🙂

  • @harshavardhan184
    @harshavardhan184 3 ปีที่แล้ว +3

    *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! 😊

  • @thebrg
    @thebrg 3 ปีที่แล้ว

    Your Videos are Awesome.🇳🇵🇳🇵

  • @ehabtalaat10
    @ehabtalaat10 6 ปีที่แล้ว

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

  • @vijaya4870
    @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 😊

  • @rajeshmudavath3769
    @rajeshmudavath3769 3 ปีที่แล้ว +2

    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

  • @hasleyindiahasley9718
    @hasleyindiahasley9718 6 ปีที่แล้ว +3

    Thanku sir ..
    Plz help in python

    • @harshkathpal5806
      @harshkathpal5806 4 ปีที่แล้ว

      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))

  • @prog2597
    @prog2597 4 ปีที่แล้ว +8

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

    • @kushal_Yt
      @kushal_Yt 4 ปีที่แล้ว +7

      but its centurial year and not divisible by 400 !

    • @tayyab.sheikh
      @tayyab.sheikh ปีที่แล้ว

      But what about the calendar, it has 28 days in it.

  • @MsLetishia
    @MsLetishia 11 หลายเดือนก่อน

    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;

  • @goutamghosh8809
    @goutamghosh8809 3 ปีที่แล้ว +1

    Which app is used for the execution? Can you please tell me sir

    • @pravinkakade8810
      @pravinkakade8810 3 ปีที่แล้ว +1

      codeblock....... download and install...... watch initial some video

    • @goutamghosh8809
      @goutamghosh8809 3 ปีที่แล้ว +2

      @@pravinkakade8810 Thank you very much 😃 I have already searched this and got the app. It's a great app really 😃

    • @abhishekhugar212
      @abhishekhugar212 3 ปีที่แล้ว +1

      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
      @goutamghosh8809 3 ปีที่แล้ว +1

      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
    @mohammedisarezwani ปีที่แล้ว +1

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

  • @carl5720
    @carl5720 3 ปีที่แล้ว

    Sir how to put trivia on each year?

  • @mohammaddawoodomidi2169
    @mohammaddawoodomidi2169 3 ปีที่แล้ว +1

    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
      @patalamrithish6838 3 ปีที่แล้ว +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

  • @dambro3312
    @dambro3312 2 ปีที่แล้ว +1

    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);

  • @avinashchourasiya3463
    @avinashchourasiya3463 5 ปีที่แล้ว +3

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

    • @EverythingTechWithMustafa
      @EverythingTechWithMustafa 5 ปีที่แล้ว

      Century year leap year nahi hota

    • @prog2597
      @prog2597 4 ปีที่แล้ว

      @@EverythingTechWithMustafa nope after checking the divisibility of 4 and 400

    • @prog2597
      @prog2597 4 ปีที่แล้ว

      But 1990 is not a leap year, not divisible by 4 and 400

  • @mothukuriomsaiprakash2999
    @mothukuriomsaiprakash2999 4 ปีที่แล้ว +1

    what about 200 it is divisible by 100 and 4

    • @mehadihasansanto538
      @mehadihasansanto538 4 ปีที่แล้ว +1

      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
    @tanushree4088 4 ปีที่แล้ว +1

    Please tell y 400%and 100% is used here

    • @pritisharaychaudhuri7599
      @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,

  • @4olufade
    @4olufade 4 หลายเดือนก่อน

    If 1896 and 1904 were leap year, then 1900 was a leap year. the only test should be if(year % 4)

  • @kaushikigoel759
    @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😶!

  • @sukhbeersingh5811
    @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
      @camerald8257 3 ปีที่แล้ว +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
      @gurusamyd9531 3 ปีที่แล้ว

      If(year%==0) sir why we put ==0

    • @koustavbetal
      @koustavbetal 3 ปีที่แล้ว +1

      Hey and what about 1800.
      This is devisable to 4 so does that mean it's a leap year ?? Nope..

  • @itsbayahmed
    @itsbayahmed ปีที่แล้ว +1

    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);
    }

  • @SKashyap3
    @SKashyap3 ปีที่แล้ว +2

    you didnot explain clearly.

  • @PankajKP
    @PankajKP 6 ปีที่แล้ว +1

    1 st view 1st like 1st comment

  • @krutarthpatel6537
    @krutarthpatel6537 4 ปีที่แล้ว +1

    👌

  • @ritikshrivastava9442
    @ritikshrivastava9442 4 ปีที่แล้ว +1

    #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

  • @anandkumar-bd2ru
    @anandkumar-bd2ru 2 ปีที่แล้ว

    if(year %100==10)
    {
    if (year%400 ==0)
    leap year
    }
    else
    if (year %4) ==0
    leap year

  • @yaswanths5382
    @yaswanths5382 3 ปีที่แล้ว

    Sir did you got cold while you teaching this session 🙂🙂😂

  • @omgaikwad0510
    @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
      @ankitaman7890 3 ปีที่แล้ว +2

      You are using "or" operator here but the catch is we have to solve it only with the if,elseif and else condition.

    • @omgaikwad0510
      @omgaikwad0510 3 ปีที่แล้ว

      @@ankitaman7890 Ok

    • @shreya5382
      @shreya5382 3 หลายเดือนก่อน

      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.