How to evaluate multiple increments in the same line? (++a + a++ - ++a)

Поделиться
HTML-код
  • Опубликовано: 4 янв 2021
  • Source code can be found here:
    code-vault.net/lesson/bpkp5hu...
    ===== Support us through our store =====
    code-vault.net/shop
    ===== Check out our website =====
    code-vault.net
    ===== Check out our Discord server =====
    discord.code-vault.net

Комментарии • 27

  • @adrianstanea6236
    @adrianstanea6236 3 года назад +4

    I just checked this and kinda found a logic explanation for the case when output is 6. The increment operator has the highest precedence in this case, so first it evaluates all these operations from left to right, then it proceeds to do the arithmetical operations

  • @tharindumandusanka7708
    @tharindumandusanka7708 2 года назад +1

    Thanks for your work sir

  • @tinpham6413
    @tinpham6413 3 года назад +1

    What is your keyboard name bro, that sound so great

    • @CodeVault
      @CodeVault  3 года назад +1

      It's a Das Keyboard Model S with brown switches. I like it too, much more than other mechanical keyboards!

  • @asifsaad5827
    @asifsaad5827 3 года назад

    i have the same code run on various version of GCC compiler and they all are showing 6

  • @LSK-kb1xu
    @LSK-kb1xu 3 года назад +2

    Could you make a detailed video on recursion please? You explain so well...it would be of a big help to lot of us. I have an upcoming xm in 10 days so a video on the topic would really help. Thank you so much. :D

    • @CodeVault
      @CodeVault  3 года назад +2

      I'll look into that next week I think

    • @LSK-kb1xu
      @LSK-kb1xu 3 года назад +1

      @@CodeVault thanks a lot..🤗❤

  • @bekausi
    @bekausi Год назад

    Help, I must be missing something. I don't understand why incrementing from left to right the Fourth increment is not evaluated to 4, and when incrementing from right to left the value of the First increment is not 1.

    • @CodeVault
      @CodeVault  Год назад +1

      Because a++ first evaluates the value of a and *then* it increments it.
      int a = 0;
      printf("%d
      ", ++a); // here you get 1 printed on the screen
      // a is 1 from here on out
      int a = 0;
      printf("%d
      ", a++); // here you get 0 printed on the screen
      // a is also 1 from here on out
      So the value of a is first passe to printf and, only after executing the printf statement, it gets incremented. After the expression, both pieces of code have the same effect (adding 1 to a)

  • @bsgamer5069
    @bsgamer5069 3 года назад +1

    Waiting for bubble sort,selection sort,quick sort 😁. But I don’t like merge sort. 😂

  • @its_code
    @its_code Год назад

    ❤❤❤❤

  • @k_ushagra
    @k_ushagra 3 года назад

    please make videos on IPC and linux kernel device drivers

    • @CodeVault
      @CodeVault  3 года назад +1

      I'll keep it mind! Thanks

  • @vijaysurywanshi87
    @vijaysurywanshi87 3 года назад

    can u make video for midium level students for c programming

    • @CodeVault
      @CodeVault  3 года назад

      Yea, I have quite a few videos for people that already somewhat know C programming. Do you have anything specific in mind?

    • @vijaysurywanshi87
      @vijaysurywanshi87 3 года назад

      @@CodeVault recursive function,pointer ,pointer within pointer,structure etcccc. (.but start from basic to expert level )
      Create lengthy video, in every part put at least 3~4 example related topic.🤗

    • @CodeVault
      @CodeVault  3 года назад

      Hmm, this could be well received as a paid course. Will look into it

  • @ajithanandhan7009
    @ajithanandhan7009 Год назад

    How to become pro in c programming please tell the way to practice every day I didn’t get the way to be good at it.

    • @CodeVault
      @CodeVault  Год назад

      I'm no "pro" but I would say you can start by creating a simple project that you keep on adding to (something like a calculator in the terminal, then you add more complex operations to it, after that you make it work for any base number, then maybe even add a GUI to it etc.). Whenever there is something that you don't know or don't understand just google on the internet and (if possible) read the official documentation

    • @ajithanandhan7009
      @ajithanandhan7009 Год назад

      @@CodeVault thanks for your valuable words i will do this way.for me ur a pro cause i have attended a Robert Bosch interview they asked me difference between declaring and definition of a variable at the i time i was confused after seeing ur video on that topic got clear idea,the way you explain things i can catchup easily btw im an 24 year old embedded software developer from india

    • @CodeVault
      @CodeVault  Год назад

      Wow, very cool! Honestly, I don't have much professional experience in C. I try to share whatever I learned so far. Since you're working in the embedded field you probably know (or will know in the future) more than I do about the language

    • @ajithanandhan7009
      @ajithanandhan7009 Год назад

      @@CodeVault yeah i will, in my opinion you’re so good at understanding things keep doing it also you’re one of the good content creater in youtube 😁

  • @shayanrao3000
    @shayanrao3000 8 месяцев назад

    Your accent is inunderstamdable.

    • @CodeVault
      @CodeVault  8 месяцев назад

      You can use youtube captions to help you understand the videos better

  • @sameeranand6823
    @sameeranand6823 3 года назад +1

    #include
    main()
    {
    int n;
    n=f1(4);
    printf("%d",n);
    }
    f1(int x)
    {
    int b;
    if(x==1)
    return 1;
    else
    b=x*f1(x-1);
    return b;
    }
    explain recursion

    • @CodeVault
      @CodeVault  3 года назад +1

      I will do a video on recursion sometime this month