C do while loop 🤸‍♂️

preview_player
Показать описание
C do while loop tutorial example explained

#C #do #loop
Рекомендации по теме
Комментарии
Автор

#include <stdio.h>

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

BroCodez
Автор

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

cadyneisfeld
Автор

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

adrianedge
Автор

Can you do multiple whiles? Like 4 conditions?

reecetrahan
Автор

i didnt understand this in css50 so i came here thanks

normalhether
Автор

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

vincevangoat
Автор

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

nhano
Автор

whatever anything before or after or I do or did

ryanalnaser
Автор

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

WOLF_XXX