Это видео недоступно.
Сожалеем об этом.

C do while loop 🤸‍♂️

Поделиться
HTML-код
  • Опубликовано: 5 окт 2021
  • C do while loop tutorial example explained
    #C #do #loop

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

  • @BroCodez
    @BroCodez  2 года назад +38

    #include
    int main()
    {
    // while loop = checks a condition, THEN executes a block of code if condition is true
    // do while loop = always executes a block of code once, THEN checks a condition
    int number = 0;
    int sum = 0;
    do{
    printf("Enter a # above 0: ");
    scanf("%d", &number);
    if(number > 0)
    {
    sum += number;
    }
    }while(number > 0);

    printf("sum: %d", sum);

    return 0;
    }

    • @KaraSub2.0
      @KaraSub2.0 9 месяцев назад

      Why number is wrote as # ?

  • @cadyneisfeld540
    @cadyneisfeld540 2 года назад +5

    You just gained a new sub... You're the best

  • @adrianedge7975
    @adrianedge7975 2 года назад +16

    i was trying to research how this worked for an hour and a half now until this video, thank you

    • @adrianedge7975
      @adrianedge7975 2 года назад

      in my head i was thinking as long as the while was true the code executed but if false it didn't, not that if false it didnt REPEAT. aka it executes once regardless. Thanks again

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

    Man I wish you were my professor.

  • @normalhether5806
    @normalhether5806 Месяц назад

    i didnt understand this in css50 so i came here thanks

  • @sherzodchulliyev9163
    @sherzodchulliyev9163 Месяц назад

    great

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

    Why do we need the if? You already said while i greater 0 so you could just put the equation anyways?

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

    whatever anything before or after or I do or did

  • @user-fz6ps1su4t
    @user-fz6ps1su4t 3 месяца назад

    😍😍😍😍😍😍😍

  • @user-fs5ss4pw9l
    @user-fs5ss4pw9l 2 месяца назад

    ОД ДУШИ БРАТ
    ❤‍🩹

  • @reecetrahan6169
    @reecetrahan6169 Год назад +5

    Can you do multiple whiles? Like 4 conditions?

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

      just use && between conditions

    • @resurging6306
      @resurging6306 Год назад +2

      @@ntsd7509 or || if you want "or"

  • @nhano7712
    @nhano7712 Месяц назад

    Isn't condition (if(number >0)) redundant?

  • @AIDZ__
    @AIDZ__ Год назад +2

    I dont get it again.... goddamnit

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

    what is printf?

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

      input

    • @danny0.o
      @danny0.o 3 месяца назад

      'printf' is to output to the terminal window...basically its like displaying something to the user

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

    How did we get 15 at the end?

  • @lalmi6150
    @lalmi6150 2 года назад +2

    خ

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

      ğ

    • @lalmi6150
      @lalmi6150 2 года назад

      @@spicasuzuki1908 what?

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

      @@lalmi6150 My goals are beyond your understanding.
      And üİşçöı

    • @lalmi6150
      @lalmi6150 2 года назад

      @@spicasuzuki1908 you are cool girl, i liked your type

    • @spicasuzuki1908
      @spicasuzuki1908 2 года назад

      @@lalmi6150 thanks :)

  • @WOLF_XXX0
    @WOLF_XXX0 4 месяца назад

    why is the sum 15 at the end , can someone explain me pls..

    • @danny0.o
      @danny0.o 3 месяца назад

      im prolly abit late but when he entered the values (1, 2, 3, 4, 5) it all added up together because of the 'sum', basically each value got added which added up to 15
      1+2+3+4+5 = 15

    • @SuryaSurya-sc1ri
      @SuryaSurya-sc1ri 8 дней назад

      @@danny0.o Can you explain sum +=number;