wooowe man a while loop that would't end and goes on forever!!! thats like the while loop from hell that would't die.... that would execute the statement on my pc forever scary stuff bucky scary stuff right there....anything that would't die scares me
a funny combo you can play whit. int loopcount; int hotdogs; int total; int average; int rounds; total = 0; loopcount = 0; printf("average of hours on the computer. how many days?\n"); scanf("%d", &rounds); printf("average of hours spent on the computer?\n"); while(loopcount < rounds) { printf("hours spent playing today:"); scanf("%d", &hotdogs); total = total + hotdogs; loopcount = loopcount + 1; } average = total/rounds; printf("You spend an average of %d hours a day\n", average);
Great tutorials. Am I the only one who noticed in this video he says to print total number of hot dogs to eat although we are actually displaying the average number the total? lol
third from last line should be printf ("average number of dogs was ... right? i mean average instead of total but still very helpfull and nice vids thank you
@bondservant4Him It's the purpose of the while loop, in the beggining of the video he said the while loop can execute a single code 100 times. Now, it's the example that he uses that makes me keep scratching my head. Idk why.
@halcoder "%d" means that the variable wich is receiving a value or being printed on the screen is a decimal interger. If it was "%f" it would be a floating point, else if it was "%c" it would be a character variable. The are many types os "%something", all of them mean a specific type of variable.
@SpeedCubingCentral yes and no, in scanf you are storing that variable in a memory addresss thats why you need the '&' because its a pointer pointing to a location in memory that u choose to store, but you can use an '&' in other places if you wish for instance in a function parameter.
The only "confusing" part would be (for the ones not watching this realy carefuly),would be the execution of the program. Instead of "TOTAL" number of hotdogs eaten,you should put like "average hotdogs eaten" good tut
@howdouwin Later on when you get better there may be a situation where you want music to play while you're in a certain pert of the game. the if statement will only play through the music once, where as a while loop will play the music over and over and over until you get past that part of the game.
@bondservant4Him lol. I am currently using C++ and the simpliest way i know to use music is simply doing system("MUSICNAMEHERE.mp3"); of course you would replace 'musicnamehere' with the name of the file. as far as i know it only works with mp3'ss but you could try a .wav
@bondservant4Him Yes, but unfortuently instead of running it in the background it opens the file up. Thankfully you can still go through the program while the music plays.
Why did you declare loopcount twice instead of just initializing it? As far as the average and total count of hotdogs, I'm sure it was most likely just a simple mistake. Thanks for taking the time to make these videos even if there is an occasional mistake:P
Actually I buy American branded hot dogs here in Oz and have one per week on a fresh roll with lettuce and,beetroot and Aussie Mustard ..nothing better.
I will use this program to average out my intake over the year ..thanx
I have a question: Why is there an & symbol before some variables when being used and at other times they are not, like in the last printf it was w/o.
@TheKencal %d means that compiler will replace %d with decimal number, which is given as parameter after , (for example %f is for float, %c for char...). And & - means "from adress" ...
hey... thanks so much for your tutorials... i'm a fan :)... emm 1 question... why does C calculate, in this case, the average and show a rounded off number. eg 22/5=4 where as it should have been 4.4 ????
he used the "int average" to indicate for variable "average" so c only take the whole number because int is integer(whole number). if u want decimal number change:
@redfoxarts their is an easy way to add up all the numbers up t a certain number. Its this formula, where x is you're number that you want to add up to
((x+1) / 2) * x
for example, you want to add up all the numbers up to 10
Hey man, great videos, I am about to continue on absorbing basic code in your next one. I noticed your last prinf said it was showing the total when it was really showing the average, very nice
when you intialise your loopcount to 0 that will be the first number it starts, as it is "loopcount<5" the loop count will get to 4 and stop. this means it will go: 0, 1, 2, 3, 4. so technically it does it 5 counts :P similarly you can make loopcount start as 1, and make " loopcount <= 5 " which will go 1,2,3,4,5. i hope that helps
wooowe man a while loop that would't end and goes on forever!!! thats like the while loop from hell that would't die.... that would execute the statement on my pc forever scary stuff bucky scary stuff right there....anything that would't die scares me
dheer730 1 week ago
How can you make 7 tutorials with the end bracket indented, it's making me crazy :p
MrKiller00224 1 week ago
Now I'm hungry for hotdogs
karabera123 2 weeks ago
im getting 124498 everytime as average for some reason
tadm123 2 weeks ago
@tadm123 you need to initialize average to 0 before using it
bondservant4Him 2 weeks ago
@tadm123 pardon me i meant to say make sure total is initialized to 0
bondservant4Him 2 weeks ago
i know the beginning and the end not there sorry...
hardstylegronne 1 month ago
Comment removed
hardstylegronne 1 month ago
hardstylegronne 1 month ago
I have a question , if i want that the average can be a not complete number
like 8.54 or 7.6 how do i do it?
i tried to do float average but it does alway avereage = 0
thank for helping :)
RonSerruya1 1 month ago
@RonSerruya1 type cast your integers to doubles or floats first
bondservant4Him 1 month ago
Thank you so much !
I succsed to learn loops in 10 min thanks to you ;]
great toturial :)
RonSerruya1 1 month ago
It says "syntax error before int" and it did the same earlier when I used the "else" function. Whats wrong?
yonchvader 1 month ago in playlist C Programming Tutorials
@yonchvader did you copy his code word for word?
bondservant4Him 1 month ago in playlist C Programming Tutorials
was 17?
fods202 1 month ago
printf("Bucky is the best damn teacher in the whole world");
Ausamnco 1 month ago 2
@Ausamnco You forgot to include your header files , main function and getch(); Troll :) ( its a joke ) :P
bradbrock1 1 month ago in playlist C Programming Tutorials
Get down and dirty with bucky and eat hotdogs? That doesn't sound wrong at all.
ElementGriefing 1 month ago in playlist C Programming Tutorials
=0; looks like a face lol
MaxOp1234 2 months ago
If you use the total as the result then it can be used as a way to add up multiple numbers
97epicman 2 months ago in playlist C Programming Tutorials
that my friend prints average, not total! haha :P
Shockszzbyyous 2 months ago in playlist More videos from thenewboston
loopcount++;?
gudenaurock 2 months ago in playlist C Programming Tutorials
Its gonna execute the Coug....Code.
ellondu 2 months ago
Great tutorials. Am I the only one who noticed in this video he says to print total number of hot dogs to eat although we are actually displaying the average number the total? lol
josiahsavino 3 months ago
YOU ARE MY GOD SIR,Whereever you are you will live fine!!
sudharsan94 3 months ago
*down and dirty
liamlemur 3 months ago
plz.........help me out with strings and pointers
jack9902300 3 months ago
Man you r addicted to dogs.........
2601AKASH 4 months ago
"enter number of dogs ate"
xDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
tigerLRg245 4 months ago
no thank you!
s0psAA 4 months ago
third from last line should be printf ("average number of dogs was ... right? i mean average instead of total but still very helpfull and nice vids thank you
sepia2008 4 months ago 14
Like if you kept moving your mouse trying to get the cursor in the video out the way lol
tw3857 5 months ago
he said dont let me forget lol like we can remind him
MoreThanGrades10552 5 months ago
thanks bucky, hope i can answer my exams which basically on c..
btw subscribed :)
shdin271 5 months ago
Comment removed
Kaishaku95 5 months ago
68,366 got done and dirty with Bucky; you slut
NoamElBaZ 6 months ago in playlist TheNewBoston - C Programming 2
it Dont matter i figured it out i was using a & when it should of been a %
Ashleywv3 6 months ago
i get a problem, when i test the code at the end, i type in 1 and press enter the it skips to getch(); and it says the average is 2293576
Ashleywv3 6 months ago
fix your output msg, you print the average number of dogs you have eaten in the last 5 days while calling it total number of dogs ...
Missed that :P !
aquaba17 6 months ago
what about "%s"? Isn't that used for, buffering?
MrUvA1337 6 months ago
for more efficiency u can do
total += hotdogs; //same as total= total + hotdogs;
loopcounter++; // same as loopcounter = loopcounter + 1;
anyways nice vdo :)
himmatsingh1991 6 months ago
No matter what i do I get a total of 2686776, and an average of 2686780. I have checked my code many times. Does anyone know what might be wrong?
UnchainTheNight1 6 months ago
@UnchainTheNight1 funny i get exactly the same... hmm... Gotta look it throu again again
tuttar3 6 months ago
@UnchainTheNight1 Hey again i found my problem perhabs you did the same. i forgot to take the average= total/5; out of the while loop.
Hope it helps you
tuttar3 6 months ago
@tuttar3 I finally got it worked out. It was a syntax error.
UnchainTheNight1 6 months ago
I was confused during this whole tutorial, I'll just find something else on the web and continue this specific series.
TheVerbalAxiom 6 months ago
@TheVerbalAxiom what confused yu?
bondservant4Him 6 months ago
@bondservant4Him It's the purpose of the while loop, in the beggining of the video he said the while loop can execute a single code 100 times. Now, it's the example that he uses that makes me keep scratching my head. Idk why.
TheVerbalAxiom 6 months ago
i ate only 2 dogs ._.
mastermax7777 6 months ago
x_x did you just say you ate 17 dogs? /puke
cookiesRgood26 7 months ago
what is "%d"? My english is not perfect and i'm not understand all :(.
halcoder 7 months ago
@halcoder %d is used for an integer or whole number
bondservant4Him 7 months ago
@bondservant4Him thanks
halcoder 7 months ago
@halcoder "%d" means that the variable wich is receiving a value or being printed on the screen is a decimal interger. If it was "%f" it would be a floating point, else if it was "%c" it would be a character variable. The are many types os "%something", all of them mean a specific type of variable.
moraleidahgo 6 months ago
to get a more accurate average, use floats / doubles;
float hotdogs;
float total;
float average;
scanf("%f", &hotdogs);
average=total/days;
printf("you ate a total of %f hotdogs", average);
Cyphlix 7 months ago
@Cyphlix or you could just type cast
bondservant4Him 7 months ago
instead of loopcount = loopcount + 1;
you could just type loopcount += 1;
SlateHayes 8 months ago
i want another example for while loop.
thnks.
DOVARIRAMU 8 months ago
Do you only need to use a "&" when you are using "scanf" statements?
SpeedCubingCentral 8 months ago
@SpeedCubingCentral yes and no, in scanf you are storing that variable in a memory addresss thats why you need the '&' because its a pointer pointing to a location in memory that u choose to store, but you can use an '&' in other places if you wish for instance in a function parameter.
bondservant4Him 8 months ago
@bondservant4Him Ah, thanks, that makes sense.
SpeedCubingCentral 8 months ago
The only "confusing" part would be (for the ones not watching this realy carefuly),would be the execution of the program. Instead of "TOTAL" number of hotdogs eaten,you should put like "average hotdogs eaten" good tut
Novica89 8 months ago
instead of saying loopcount = loopcount +1
it is much easier saying loopcount++
which has the same effect it adds 1 to loopcount every time the loop is executed
mcholera1 9 months ago
@mcholera1 Thanks, i just learned somethng useful from your comment and did not even watch the video yet :D
Antarktida1337 8 months ago
dude ive covered almost 3 chapters in my engineering computation textbook in less than an hour, EXCELLENT WORK!
foosta5 9 months ago
where is this code??i didnt found it in your website..
mircheda41 9 months ago
Why cant you just use an if statement and not while? As in saying if the total number is <5.
howdouwin 9 months ago
@howdouwin Later on when you get better there may be a situation where you want music to play while you're in a certain pert of the game. the if statement will only play through the music once, where as a while loop will play the music over and over and over until you get past that part of the game.
Logart8 9 months ago
@Logart8 how would you go about adding music is that done in C?
bondservant4Him 9 months ago
@bondservant4Him lol. I am currently using C++ and the simpliest way i know to use music is simply doing system("MUSICNAMEHERE.mp3"); of course you would replace 'musicnamehere' with the name of the file. as far as i know it only works with mp3'ss but you could try a .wav
Logart8 9 months ago
@Logart8 does it work at the command line? when u run your program?
bondservant4Him 9 months ago
@bondservant4Him Yes, but unfortuently instead of running it in the background it opens the file up. Thankfully you can still go through the program while the music plays.
Logart8 9 months ago
@Logart8 nicee man i never knew that thanks
bondservant4Him 9 months ago
@bondservant4Him np
Logart8 9 months ago
can someone make a os without Assembly? and how hard is it to learn? and could I just put in a little code from someone else so my c code would work?
TheLitefire 10 months ago
Thank you so much for uploading this videos .U made learning C programming so easy
sumatijadhav 10 months ago
@blakestrasel1 lolz,
in fact, the chinese can eat everything from those small cockroaches to persons like u as well...
vivekkumardaga 10 months ago
hacking is different from this. Changing a few variables is much easier than the architecture of a whole program.
deathbyaccident 11 months ago
*GASP* u ate an average of 17 dogs ! :O .. DOG EATER !
7250706 11 months ago
jou'r a verry good teacher :)
12white1 11 months ago
Why did you declare loopcount twice instead of just initializing it? As far as the average and total count of hotdogs, I'm sure it was most likely just a simple mistake. Thanks for taking the time to make these videos even if there is an occasional mistake:P
nulledsession 11 months ago
tnx to that video. it helps a lot how to use that while loop :)
mhaine061 1 year ago
wow dude I have truly learned so much Thanks!
Elymquez 1 year ago
Comment removed
IEOA 1 year ago
That's not a money that's an ampersand!!!!!
DrVerruckt 1 year ago
@DrVerruckt lmao, that was funny but it was informative, I appreciate this video
drearystate 11 months ago 2
tbh i feel you stole all of marks tutorials, in same order, same things, exactly.
DeeWeext 1 year ago
That was not the total amount of dogs eaten. It was the average of the values entered at the first prompt of the loop. And loopcount++ :D
UnixReviews 1 year ago
Cs50.net
Jugdesi 1 year ago
This has been flagged as spam show
could you please email me an example of 3D game code? (anything)
I heard its a nightmare but i dont believe it.....
jonima123@hotmail.com
JONIMASAKIS 1 year ago
Why not use total += hotdogs; instead of total = total + hotdogs;
Xaezes 1 year ago
@Xaezes
Most likely To Show people how it breaks down.
Mexicouger 1 year ago
loopcount++;
:p
signofdevil666 1 year ago
You ate 54 American hot dogs in one day..?
Actually I buy American branded hot dogs here in Oz and have one per week on a fresh roll with lettuce and,beetroot and Aussie Mustard ..nothing better.
I will use this program to average out my intake over the year ..thanx
Jp
johnpro2 1 year ago
nice integer division there, chief. the average number of dogs eaten is 17.6, not 17.
VelocityTheory 1 year ago
@VelocityTheory dude as u can c he defined "average" as integer......
integer dosent accept decimal values, to obtain decimal values u gotta define it as - float average; :)
HeaRtForGamInG 1 year ago
I have a question: Why is there an & symbol before some variables when being used and at other times they are not, like in the last printf it was w/o.
MrDanielHen 1 year ago
@gagoff nope you can write
loopcount++
or
++loopcount
I prefer "variable_name++"
petemaguire2 1 year ago
Wow! He ate 54 dogs the 3rd day!!!
I can't really eat that much...
anyways... his examples are really funny...
BulletForMyTeachers 1 year ago
thumbsup
spydude20 1 year ago
just reminding you
CHANGE THE VALUE OF THE LOOPCOUNT!!!
TehParody 1 year ago
This has been flagged as spam show
Great videos, really helpful :)
loopcount=loopcount+1
is the same as
++loopcount (increment)
petemaguire2 1 year ago
Great videos, really helpful :)
loopcount=loopcount+1
is the same as
++loopcount (increment)
petemaguire2 1 year ago
@petemaguire2 I used loopcount++.
Is there a difference between that and ++loopcount?
gagoff 1 year ago
thanke u very much !
wang1024 1 year ago
thanks a lot mate
Vazqo182 1 year ago
bucy, u didn't actually explained what %d and & do in thia tutorial...
TheKencal 1 year ago
@TheKencal %d means that compiler will replace %d with decimal number, which is given as parameter after , (for example %f is for float, %c for char...). And & - means "from adress" ...
mafian89 1 year ago
For some reason, this looks like it works the same with a for loop. What's the difference between that and a while loop?
EnvyMizuhashi 1 year ago
hey... thanks so much for your tutorials... i'm a fan :)... emm 1 question... why does C calculate, in this case, the average and show a rounded off number. eg 22/5=4 where as it should have been 4.4 ????
arseshan 1 year ago
@arseshan
he used the "int average" to indicate for variable "average" so c only take the whole number because int is integer(whole number). if u want decimal number change:
"int average;" to "float average"
and
printf("the number of dogs was &d" average);
to
printf("the number of dogs was &f" average);
gyman89 1 year ago
aww i really wanna hotdog now XD
also get tutorials :D gonna watch them all :)
minieggg1 1 year ago
thanks..
ellveetrapz 1 year ago
tnx
rian438 1 year ago
Great Tutorial.
TheDarkSagan 1 year ago
You eat 54 Hotdogs?
Wow!
Anyway, Thank you very MUCH!!!
ScienceTutorials 1 year ago
amazing tut, thanks!
SamiEntertainment 1 year ago
mate well done!! cheers for the help!
CravenGold21 1 year ago
[loopcount++] is shorter than [loopcount = loopcount + 1]
trippplep 1 year ago
[total+=hotdogs] is another way of writing [total = total + hotdogs]
trippplep 1 year ago
int loopcount = 0, hotdogs, total = 0, average; and loopcount++
should make things simpler
ender2070 1 year ago
don't eat my dog
MattPol219 1 year ago
is loop equal to cycle??
lena4player5 1 year ago
helpfull~
lyrebaby 1 year ago
don't you mean the mean/agerage was 17?
197022007 1 year ago
2+4+54+22+6= 17???
burnfaint21 1 year ago
@burnfaint21 the average = 17 its in the code...the output shoudl say average
pwntastic2000 1 year ago
@burnfaint21
twilight1234g 1 year ago
loopcount ++ as increment would have work as well
Djluv5 1 year ago
greetings from florida<3! thanks so much this really helped me! -kell
MsKelliKelli 2 years ago
Hi florida
greetings from Cali =P
Arkimedes999 2 years ago
sweet! on the coast? or inland?
MsKelliKelli 2 years ago
how about the for loop.
stonechime18 2 years ago
Im your big fan!!!
redfoxarts 2 years ago
why do you have conio?.
What about this one:
Enter a number: 4 (for example)
The sum is: 10
========
1+2+3+4= 10!!!
couldnt get the code
redfoxarts 2 years ago
@redfoxarts their is an easy way to add up all the numbers up t a certain number. Its this formula, where x is you're number that you want to add up to
((x+1) / 2) * x
for example, you want to add up all the numbers up to 10
(11 / 2) x 10 = 55
0121ryanh117 2 years ago
dude, your last printf statement have to say total average of hotdogs, not total number of DOGS,
anyway, thanks for the video, is very helpful. :-)
TheALPHAKILLER 2 years ago 26
@TheALPHAKILLER
That's ok..just change it .....
Jp
johnpro2 1 year ago
@TheALPHAKILLER - lolz...
vivekkumardaga 10 months ago
@TheALPHAKILLER hey buddy, dont bother! it is dog, n ll remain dog, even if it is hot or cold...
lolz..
vivekkumardaga 10 months ago
u could also just total += hotdogs; and also loopcount++;
dumbxkid 2 years ago
hey, what compiler are you using?
patzkatigbak 2 years ago
its dev C++
dumbxkid 2 years ago
@CzSoft hacking is appreciated, you dont have to hack for bad, you can hack for good. trust me
0121ryanh117 2 years ago
it was meant to be joke :0))
PR3DAT0RY 2 years ago
Hey man, great videos, I am about to continue on absorbing basic code in your next one. I noticed your last prinf said it was showing the total when it was really showing the average, very nice
rowing1s4me 2 years ago
i dont get it, i will never be hacker lol :0)
PR3DAT0RY 2 years ago
@PR3DAT0RY
Learning to program is not about becoming a hacker. Indeed, becoming a hacker requires you to become a programmer, but not vise versa.
BufferOverflowAttack 2 years ago
This has been flagged as spam show
bwahahaha.... why "DOG"?
LoL XD
VinzParamore 2 years ago
bwahahaha..... why "DOG"?
LoL XD
VinzParamore 2 years ago
Can you build GUI's for this?
efcfan1234 2 years ago
@efcfan1234 look into the windows api. My channel has some tutorials on the windows api
0121ryanh117 2 years ago
that's not an money thats an ampersaind?
You really make a lot of funny mistakes, LOL
anyway I thanks for all the videos this is an awesome start, before reading books on C language
bboybram 2 years ago
very helpful, 5 stars
AnimalwweMania 2 years ago
i should be average_total lol but great vid.... i should be ready for finals by the time i finish channel
denrickjack 2 years ago
I loled at 54..someone does that? Lol, anyway, your videos are really awesome..5 stars
blackdefender 2 years ago
average number of hotdogs was %d
not total number of dogs
tanertino1 2 years ago
Comment removed
Snowwolf34155 2 years ago
I have a question. when do we need to open a new brace. Like why couldn't we include average in the same brace
princeshewi 2 years ago
the loopcount should not get to 5 because u put loopcpount < 5;
gudukassa 2 years ago 2
can it be because it started from zero? I am confused too.
princeshewi 2 years ago
when you intialise your loopcount to 0 that will be the first number it starts, as it is "loopcount<5" the loop count will get to 4 and stop. this means it will go: 0, 1, 2, 3, 4. so technically it does it 5 counts :P similarly you can make loopcount start as 1, and make " loopcount <= 5 " which will go 1,2,3,4,5. i hope that helps
alchemitch 2 years ago 2
getchar() is part of stand I/O library. getch() is not.
motionnyan 2 years ago
why print total number of dogs when the output is the average number o.O
pwntastic2000 2 years ago
thx ,all your tutorials are awesome
xxyuri 2 years ago
you can just initialize total and loopcount to zero where u delcare it rite? you dont have to do that again
ScrapyDan 2 years ago
these videos are really useful, I'm in a programming class right now.
TheThissucks123 2 years ago
getchar(); works in a Win enviroment but not Linux.
OlsenCNC 2 years ago
WRONG. getchar(); runs fine on linux :P
itsbrad212 2 years ago
Someone thumbed yu down don't know why, since your right.
GCC works fine with getchar();
bboybram 2 years ago
@bboybram Finally, someone who understands programming :D
itsbrad212 2 years ago
Does the following not work in a Win environment?
getchar();
zachgoestoeuro 2 years ago
try, system ("pause");
808hawk 2 years ago
ahhh i got it Awesome Dude :)
NawafLol 2 years ago
thanks..u really are my saviour
vicsilverhalo 2 years ago