Added: 3 years ago
From: thenewboston
Views: 95,895
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (193)

Sign In or Sign Up now to post a comment!
  • 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

  • How can you make 7 tutorials with the end bracket indented, it's making me crazy :p

  • Now I'm hungry for hotdogs

  • im getting 124498 everytime as average for some reason

  • @tadm123 you need to initialize average to 0 before using it

  • @tadm123 pardon me i meant to say make sure total is initialized to 0

  • i know the beginning and the end not there sorry...

  • Comment removed

  • 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);
  • 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 type cast your integers to doubles or floats first

  • Thank you so much !

    I succsed to learn loops in 10 min thanks to you ;]

    great toturial :)

  • It says "syntax error before int" and it did the same earlier when I used the "else" function. Whats wrong?

  • @yonchvader did you copy his code word for word?

  • was 17?

  • printf("Bucky is the best damn teacher in the whole world");

  • @Ausamnco You forgot to include your header files , main function and getch(); Troll :) ( its a joke ) :P

  • Get down and dirty with bucky and eat hotdogs? That doesn't sound wrong at all.

  • =0; looks like a face lol

  • If you use the total as the result then it can be used as a way to add up multiple numbers

  • that my friend prints average, not total! haha :P

  • loopcount++;?

  • Its gonna execute the Coug....Code.

  • 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

  • YOU ARE MY GOD SIR,Whereever you are you will live fine!!

  • *down and dirty

  • plz.........help me out with strings and pointers

    

  • Man you r addicted to dogs.........

  • "enter number of dogs ate"

    xDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

  • no thank you!

    

  • 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

  • Like if you kept moving your mouse trying to get the cursor in the video out the way lol

  • he said dont let me forget lol like we can remind him

  • thanks bucky, hope i can answer my exams which basically on c..

    btw subscribed :)

  • Comment removed

  • 68,366 got done and dirty with Bucky; you slut

  • it Dont matter i figured it out i was using a & when it should of been a %

  • 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

  • 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 !

  • what about "%s"? Isn't that used for, buffering?

  • for more efficiency u can do

    total += hotdogs; //same as total= total + hotdogs;

    loopcounter++;  // same as loopcounter = loopcounter + 1;

    anyways nice vdo :)

  • 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 funny i get exactly the same... hmm... Gotta look it throu again again

  • @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 I finally got it worked out. It was a syntax error.

  • I was confused during this whole tutorial, I'll just find something else on the web and continue this specific series.

  • @TheVerbalAxiom what confused yu?

  • @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.

  • i ate only 2 dogs ._.

  • x_x did you just say you ate 17 dogs? /puke

  • what is "%d"? My english is not perfect and i'm not understand all :(.

  • @halcoder %d is used for an integer or whole number

  • @bondservant4Him thanks

  • @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.

  • 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 or you could just type cast

  • instead of loopcount = loopcount + 1;

    you could just type loopcount += 1;

  • i want another example for while loop.

    thnks.

  • Do you only need to use a "&" when you are using "scanf" statements?

  • @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 Ah, thanks, that makes sense.

  • 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

  • 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 Thanks, i just learned somethng useful from your comment and did not even watch the video yet :D

  • dude ive covered almost 3 chapters in my engineering computation textbook in less than an hour, EXCELLENT WORK!

  • where is this code??i didnt found it in your website..

  • Why cant you just use an if statement and not while? As in saying if the total number is <5.

  • @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 how would you go about adding music is that done in C?

  • @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 does it work at the command line? when u run your program?

  • @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 nicee man i never knew that thanks

  • 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?

  • Thank you so much for uploading this videos .U made learning C programming so easy

  • @blakestrasel1 lolz,

    in fact, the chinese can eat everything from those small cockroaches to persons like u as well...

  • hacking is different from this. Changing a few variables is much easier than the architecture of a whole program.

  • *GASP* u ate an average of 17 dogs ! :O .. DOG EATER !

  • jou'r a verry good teacher :)

  • 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

  • tnx to that video. it helps a lot how to use that while loop :)

  • wow dude I have truly learned so much Thanks!

    

  • Comment removed

  • That's not a money that's an ampersand!!!!!

  • @DrVerruckt lmao, that was funny but it was informative, I appreciate this video

  • tbh i feel you stole all of marks tutorials, in same order, same things, exactly.

  • 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

  • Cs50.net

  • Why not use total += hotdogs; instead of total = total + hotdogs;

  • @Xaezes

    Most likely To Show people how it breaks down.

  • loopcount++;

    :p

  • 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

  • nice integer division there, chief. the average number of dogs eaten is 17.6, not 17.

  • @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; :)

  • 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.

  • @gagoff nope you can write

    loopcount++

    or

    ++loopcount

    I prefer "variable_name++"

  • Wow! He ate 54 dogs the 3rd day!!!

    I can't really eat that much...

    anyways... his examples are really funny...

  • thumbsup

  • just reminding you

    CHANGE THE VALUE OF THE LOOPCOUNT!!!

  • Great videos, really helpful :)

    loopcount=loopcount+1

    is the same as

    ++loopcount (increment)

  • @petemaguire2 I used loopcount++.

    Is there a difference between that and ++loopcount?

  • thanke u very much !

  • thanks a lot mate

  • bucy, u didn't actually explained what %d and & do in thia tutorial...

  • @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" ...

  • For some reason, this looks like it works the same with a for loop. What's the difference between that and a while loop?

  • 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

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

  • aww i really wanna hotdog now XD

    also get tutorials :D gonna watch them all :)

  • thanks..

  • tnx

  • Great Tutorial.

  • You eat 54 Hotdogs?

    Wow!

    Anyway, Thank you very MUCH!!!

  • amazing tut, thanks!

  • mate well done!! cheers for the help!

  • [loopcount++] is shorter than [loopcount = loopcount + 1]

  • [total+=hotdogs] is another way of writing [total = total + hotdogs]

    

  • int loopcount = 0, hotdogs, total = 0, average; and loopcount++

    should make things simpler

  • don't eat my dog

  • is loop equal to cycle??

  • helpfull~

  • don't you mean the mean/agerage was 17?

  • 2+4+54+22+6= 17???

  • @burnfaint21 the average = 17 its in the code...the output shoudl say average

  • loopcount ++ as increment would have work as well

  • greetings from florida<3! thanks so much this really helped me! -kell

  • Hi florida

    greetings from Cali =P

  • sweet! on the coast? or inland?

  • how about the for loop.

  • Im your big fan!!!

  • 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 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

  • 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

    That's ok..just change it .....

    Jp

  • @TheALPHAKILLER - lolz...

  • @TheALPHAKILLER hey buddy, dont bother! it is dog, n ll remain dog, even if it is hot or cold...

    lolz..

  • u could also just total += hotdogs; and also loopcount++;

  • hey, what compiler are you using?

  • its dev C++

  • @CzSoft hacking is appreciated, you dont have to hack for bad, you can hack for good. trust me

  • it was meant to be joke  :0))

  • 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

  • i dont get it, i will never be hacker lol :0)

  • @PR3DAT0RY

    Learning to program is not about becoming a hacker. Indeed, becoming a hacker requires you to become a programmer, but not vise versa.

  • bwahahaha..... why "DOG"?

    LoL XD

  • Can you build GUI's for this?

  • @efcfan1234 look into the windows api. My channel has some tutorials on the windows api

  • 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

  • very helpful, 5 stars

  • i should be average_total lol but great vid.... i should be ready for finals by the time i finish channel

  • I loled at 54..someone does that? Lol, anyway, your videos are really awesome..5 stars

  • average number of hotdogs was %d

    not total number of dogs

  • Comment removed

  • I have a question. when do we need to open a new brace. Like why couldn't we include average in the same brace

  • the loopcount should not get to 5 because u put loopcpount < 5;

  • can it be because it started from zero? I am confused too.

  • 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

  • getchar() is part of stand I/O library. getch() is not.

  • why print total number of dogs when the output is the average number o.O

  • thx ,all your tutorials are awesome

  • you can just initialize total and loopcount to zero where u delcare it rite? you dont have to do that again

  • these videos are really useful, I'm in a programming class right now.

  • getchar(); works in a Win enviroment but not Linux.

  • WRONG. getchar(); runs fine on linux :P

  • Someone thumbed yu down don't know why, since your right.

    GCC works fine with getchar();

  • @bboybram Finally, someone who understands programming :D

  • Does the following not work in a Win environment?

    getchar();

  • try,  system ("pause");

  • ahhh i got it Awesome Dude :)

  • thanks..u really are my saviour