C Programming Tutorial – 25 – while Loops

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts


Ahmad Atari says:

so its basically a geometric progression

Arthur Kushmantsev says:

Teachers would kill kids in Russia, if they only had idea of a “while loop” in 25th lesson. I remember how Natalia Zenonovna (Computer Science teacher at school) was red faced, when we hadn`t done class-work in grade 8 just in time. May be that`s why Russian hackers R the best.

JL says:

on my mac I’m using Xcode and on the printf expression it keeps telling me data argument not used by format string for amount, which is weird because i did what you did. might be my compiler or i just need to fix something I’m not seeing.

Christine F says:

Thank you, this is really helpful!

Rauz Ranee says:

Thank you for making programming interesting to learn again…..

yerrapotu kiran says:

Thank you bucky

Brennan Jarchow says:

Why are you obsessed with tuna!

William Otuku says:

The while loop doesn’t work for me. I don’t know if it’s the problem with my compiler or computer.

ThatBigCactus says:

thank you so much man, I’m in first year engineering, i can do all the other courses but Computer programming is impossible! well it was impossible until i watched your videos!

cornelxbox25 says:

You get 107 millions not 10 millions fyi

Marcel Masqué says:

HELP! I’m a noob:)
the program works except the second time i run it it prints twice, here is what it does
the sum of three dicerolls = 10
is the second sum going to be h/l/e // q to quit: l
you suck
the sum of three dicerolls = 10
is the second sum going to be h/l/e // q to quit: the sum of three dicerolls = 8
is the second sum going to be h/l/e // q to quit:


int main()
//challenge: write a program that lets the user guess if the next dice roll sum is going to be higher, lower or equal to the previous one.
int dr1=0;
int dr2;
int dr3;
int drs1,drs2;
char guess;
int count=0;

while (count< =20) { guess=0; dr1 = (rand()%6)+1; dr2 = (rand()%6)+1; dr3 = (rand()%6)+1; drs1=dr1 +dr2+dr3; printf("the sum of three dicerolls = %dn", drs1); printf("is the second sum going to be h/l/e // q to quit: "); scanf("%c", &guess); dr1 = (rand()%6)+1; dr2 = (rand()%6)+1; dr3 = (rand()%6)+1; drs2=dr1 +dr2+dr3; if (guess=='h') { if(drs2>drs1)
printf(“you got itn”);
printf(“you suckn”);
else if(guess==’l’)

CobraL0rd says:

Fantastic example. Thank you!

IndiCoder says:

What’s the mistake here??? I am getting negative values.


int main()
int money=1000, day=1;

while( day<31 ){
printf(" Day %d: You have %d. n", day,money);
money *= 2;
return 0;

sluttyfuck19 says:

Why do i only get the tab funtion to work after day 10?`

David Mackenzie says:

Excellent tutorial, i’m learning a lot! However the answer is off by a few cents. You must use a double instead of a float. It should be $10,737,418.24

IndiCoder says:

There is no one as cool as Bucky when it comes to explaining computer Programming.

Taiquan Liu says:

I think you should use ‘double’ instead of ‘float’ here, cause the right answer should be 10737418.24. If you use float, the answer starts to go wrong on day 13.

Karen Dias says:

Thank you SO MUCH Bucky! Your vids are fun to watch and you are waaaay better than my lecturer! Thanks heaps! x

shizyninjarocks says:


michael mkundi says:

cannot clearly see the demonstrations though

Greg Bush says:

Good Stuff Man

Samir Appikatla says:

Your videos are the best tutorials I have seen. I am a 13 year old going to 9th grade.

Hangover WW says:

This Made me Quit C anyone help me with loops ?

Krystal Ion says:

Why did you put amount:$%.2f? I get that the f stands for float, but the .2 does what exactly?

Loft Music says:

learned more watching these videos than I have in the whole semester of my university programming class haha. Good work man!!

Sean Brown says:

I love you Bucky

peace bewith u says:

do you have a video on how to reject alphabeth inputs?

Xaris Razis says:

Why do i get 8million instead of f@cking 10?


int main()
   int day = 1;
   float penny = .01;
   char answer = 0;

   printf(“Would you rather have a million dollars given to you right now,or have me take from you a penny and double it every day for 1 month?n (1 for now  2 for the penny)n”);
   scanf(” %d”, &answer);

   if (answer == 1){
    while(day <= 31){ printf("Day: %d , Money: %.2f n", day, penny);     penny *= 2;     ++day;}     printf("Congratz asshole! you just lost 8mn");    }else{while(day <= 31){ printf("Day: %d , Money: %.2f n", day, penny);     penny *= 2;     ++day;}    printf("Wise man you aren");    }    return 0; }

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!