## C Programming Tutorial – 25 – while Loops

GitHub – https://github.com/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/

• Views:120,953 views
• Rating:
• Categories:
• Tags:

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:

#include
#include
#include
#include
#include

//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”);
else
printf(“you suckn”);
}
else if(guess==’l’)
{
if(drs2

CobraL0rd says:

Fantastic example. Thank you!

IndiCoder says:

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

#include
#include

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

while( day<31 ){
printf(" Day %d: You have %d. n", day,money);
money *= 2;
day++;
}
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:

Nice.

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?

#include
#include

int main()
{
int day = 1;
float penny = .01;