Тёмный
No video :(

C Programming Tutorial - 26 - do while Loops 

thenewboston
Подписаться 2,7 млн
Просмотров 258 тыс.
50% 1

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 159   
@dariacuna1442
@dariacuna1442 5 лет назад
Sucks for the student who got 0 on the first test.
@michalpitr4474
@michalpitr4474 7 лет назад
It demonstrates the Do while loop well, but I wouldn't choose 0 as the quit command since you can score 0
@muhammedzariff1098
@muhammedzariff1098 7 лет назад
How To Zoom IN : Press the windows key with "+" key then click on the "views" option after that select full screen. and increase the magnification to 200%.
@Wheelygonzales
@Wheelygonzales 10 лет назад
Where do you learn all of the things you teach in your videos? I am impressed by how much stuff you have on your channel and the variety of content from biology to computer programming to 3D animation. It's amazing! How do you do it?
@x00g40
@x00g40 10 лет назад
reading...A LOT
@SourceCodeDeleted
@SourceCodeDeleted 10 лет назад
It's not too bad... All languages are very similar and most are similar to C. I know 4 possibly more, computer languages. To me it's not about knowing one language, its about using the right language for the right problem.
@maruf7956
@maruf7956 7 лет назад
It would be better if it were zoomed in.
@muhammedzariff1098
@muhammedzariff1098 7 лет назад
press the windows key with "+" key then click on the "views" option after that select full screen. and increase the magnification to 200%.
@diyac.146
@diyac.146 7 лет назад
Muhammed Zariff what about mobile users?
@alexshepler403
@alexshepler403 6 лет назад
why don't you try full screen
@ilir124
@ilir124 5 лет назад
@@muhammedzariff1098 wow!
@webstertumala7938
@webstertumala7938 4 года назад
@Grease quala those who persevere despite having no PCs at home. Yep, me...
@tonyn2189
@tonyn2189 10 лет назад
Bucky knows lots of stuff that's for sure. Great vid.
@Dra60oN
@Dra60oN 8 лет назад
Does 'grade += scoreEntered' equals this code 'grade = grade + scoreEntered' ?
@Ibracadabra52
@Ibracadabra52 8 лет назад
+Ivan Antunović yes it does.
@shadowmeth6583
@shadowmeth6583 7 лет назад
yep
@kusumitahazra3985
@kusumitahazra3985 6 лет назад
Yes
@sarahla701
@sarahla701 5 лет назад
yes it does
@rukna3775
@rukna3775 5 лет назад
yes
@jamesbrown-yr5cz
@jamesbrown-yr5cz 9 лет назад
after 1 hour i got it!!
@over9blues490
@over9blues490 5 лет назад
had troubles understanding the condition part, but understood it after watching this, thankyou!
@briankiprono4580
@briankiprono4580 6 лет назад
Good execution of the joke made it even funnier
@haldickinson7392
@haldickinson7392 9 лет назад
bucky is a badass
@darkygames4433
@darkygames4433 8 лет назад
Dude I'm So confused About Do while loop..You r good..but u used too much Floats ha ha that's Blow my mind..I think I can understand After watching 3-5 times...Keep it up bro nice tutorials
@IDF121
@IDF121 9 лет назад
thanks a lot bucky!
@edher0707
@edher0707 Год назад
Amazing channel!
@jamesbrown-yr5cz
@jamesbrown-yr5cz 9 лет назад
i'm here now!!! =)))
@ajay000003
@ajay000003 8 лет назад
why you are using "grade" in this program. instead use total
@shizyninjarocks
@shizyninjarocks 8 лет назад
Very good explanation.
@danielalousiedingalan1532
@danielalousiedingalan1532 8 лет назад
can you zoom in your tutorials ... :D
@teachyourselfcomputerscien9178
thanks
@NavjotSingh-bz4rn
@NavjotSingh-bz4rn 5 лет назад
Your tutorials are awesome but you should increase the font size from next time
@yerrapotukiran9400
@yerrapotukiran9400 7 лет назад
Thank you Bucky
@alexperetti
@alexperetti 8 лет назад
I am trying to practice more "the do while loops" and I came across to this: Can I use characters (char) to test in a WHILE? or only numbers? I would like to create a program that requests the user to enter a name (predefined) and while this name is not typed the program will keep asking to enter the correct the name. I hope this make sense :) It didn't work: int main() { char name; printf("Once you have typed the correct name the program will stop! "); do { printf("What is the correct name?", name); scanf(" %c", &name); }while (name != 'alex'); return 0; }
@johnnyquid1152
@johnnyquid1152 8 лет назад
You can, but you made few mistakes. You don't need "name" in the end of this line ---> printf("What is the correct name?", name); Second mistake is that you typed %c insead of %s. You use %c for a single character, and for name you have to use %s. Other than that i think code should work just fine.
@alexperetti
@alexperetti 8 лет назад
Thanks a lot for your help. Indeed it worked after the correction but the program didn't break the loop once the user have typed "alex". Any thoughts?
@johnnyquid1152
@johnnyquid1152 8 лет назад
You're welcome. I don't know, maybe you entered the uppercase instead of the lowercase or something like that. Let me know what the problem was if you fix it.
@EmbeddedEngineer
@EmbeddedEngineer 8 лет назад
lol your code has a bug, not in syntax but the algorithm. if a student gets 0 which still has to be calculated in the average the program quits. Awesome job with the tutorials though!
@metalnep
@metalnep 8 лет назад
+brendon chirisah It's a great feature, because the teacher would be too depressed to enter a "0" score anyway... XD
@briansigei1989
@briansigei1989 8 лет назад
good point
@am33x
@am33x 6 лет назад
just change the last value to something below/above any grade. Like 900 or something.
@OPOD1999
@OPOD1999 10 лет назад
Hey Bucky, since you are now uploading videos and starting new series could you please make a tutorial series on scala ? It would be much appreciated :)
@benjamindemontgomery6317
@benjamindemontgomery6317 7 лет назад
Why are these videos replaced by other C# videos with relay shitty sound? These are great. how can i watch just your videos Bucky?
@mehmetsahin7313
@mehmetsahin7313 6 лет назад
First time he did a fail about programming.He wrote print :)
@MultiAkram2012
@MultiAkram2012 8 лет назад
guys, i typed in the 16th line scanf("%.0f", &scoreentered); and thanks to that my program kinda wasn't working ( please try this ) can i know why?
@yingtang9073
@yingtang9073 7 лет назад
This comment is 6 months ago. You must already know it . I think you should get rid of the .0 before the f, because it is in scanf. But, I don't know the reason why scanf doesn't need it.
@nali1511
@nali1511 6 лет назад
A great tutorial! A question: scanf() line: instead of scanf(" %f", "ScoreEntered"); I wrote scanf( " %.2f", "ScoreEntered"). The program only run once. What makes difference between %f and %.2f here? Thanks
@TheMaztercom
@TheMaztercom 2 года назад
sht im late
@jabrow7135
@jabrow7135 7 лет назад
Substitute C for 0 as the user will undoubtedly enter 0 as a score if they missed a test.
@gabemorris5370
@gabemorris5370 5 лет назад
whats the point of the do part? why not just start off with the while (scoreEntered != 0) and get rid of the do part all together?
@montanalegare4411
@montanalegare4411 8 лет назад
How do i retun back to my main function after the while condition becomes false. Once my while statement becomes false my programs ends and i need it to continue
@toni_4931
@toni_4931 2 года назад
Hi. How about when you need to have an output like this: OUTPUT Enter a number: 1 Enter a number: 2 Enter a number: 3 Sum = 6 Is it the same process?
@youtubechannelno.1135
@youtubechannelno.1135 8 лет назад
Someone give me an assignment with loops to practice? lol
@lolofuk87
@lolofuk87 5 лет назад
I have a question...Why If I put only one test with score enetered 54 and then I put 0 the average is calculated both with 54 and 0 so if I print average after the loop the result is 27?...
@TheTrauMaCoRy
@TheTrauMaCoRy 6 лет назад
I know the grade you have to declare zero but why do you declare the other variables zero? Can anyone help?
@shadowmeth6583
@shadowmeth6583 7 лет назад
It's not a bad programming practice if we leave the false condition code area empty in the shorthand if statement right? #include #include int main() { float grade = 0; float scoreEntered = 0; float numberOfTests = 0; float average = 0; printf("Press 0 when complete. "); while(true){ printf("Test:%0f\t\tAverage:%.2f ", numberOfTests, average); printf(" Enter test score: "); scanf(" %f", &scoreEntered); (scoreEntered == 0) ? break : ; grade += scoreEntered; numberOfTests++; average = grade / numberOfTests; } return 0; }
@lsenthil92
@lsenthil92 9 лет назад
grt!!
@kyriacosh4569
@kyriacosh4569 7 лет назад
how can i compare a string? for example #include #include int main() { char cmd; printf("Welcome! "); do{ printf("COMMAND>"); scanf("%c", &cmd); }while(cmd != "EXIT"); return 0; } i know i cannot do it because c recognize this as addresses. i have tried some things in stack overflow with no results. How can i compare the cmd string to not be EXIT in order to repeat? and when EXIT then exit? please help
@dandymcgee
@dandymcgee 7 лет назад
Look up the strcmp() function.
@kyriacosh4569
@kyriacosh4569 7 лет назад
its ok now i have understand the strcmp function and complete my project thanks
@yerrapotukiran9400
@yerrapotukiran9400 7 лет назад
+dandymcgee I think didn't yet say anything about strcmp() right??
@kyriacosh4569
@kyriacosh4569 7 лет назад
right. sorry man
@shadowmeth6583
@shadowmeth6583 7 лет назад
Can't you make that character cmd a string of like 50 indexes (because I have seen some really big commands of windows and linux). Because in the end test of do loop you are comparing a characrer to a string which is wrong since if cmd is a character it would never be able to hold the string "EXIT"
@jamesbotsko5950
@jamesbotsko5950 5 лет назад
How did you make it so when you clicked a variable, all of that variable was highlighted???
@amrmakhlouf7571
@amrmakhlouf7571 7 лет назад
Ty very much
@dimikeye
@dimikeye 8 лет назад
How do I use the clear screen function in do while loop
@thecasper102
@thecasper102 9 лет назад
Is there a way to clear the screen? (like "cls" in batch) And is it possible to change the color of the letters? (like "color .. " in batch)
@mrttwo
@mrttwo 10 лет назад
WOW Bucky how many programming languages do you know?
@badboarder4
@badboarder4 10 лет назад
He made C videos like 5 years ago, so he already knew this one.
@AlexGomes09
@AlexGomes09 10 лет назад
once someone knows how to code in one language(OOP) he might already has enough idea how to code in other languages (mostly). Also of course bucky for sure has so many programming books. Once I watched his video(probably C#) and later I was reading some programming book I realized bucky took that example/followed that book. Which is absolutely fine. At least someone taking initiative to lean and teach others "FOR FREE"
@falcon02012
@falcon02012 10 лет назад
if video != pointer then ?" Tutorial not complete"
@mjsanchez2173
@mjsanchez2173 6 лет назад
The text is too small. Somebody goofed up.
@sebastiandark5430
@sebastiandark5430 7 лет назад
error: 1d returned 1 exit status :(
@kayodeolanrewaju5459
@kayodeolanrewaju5459 3 года назад
so i want to calcuate the average of the marks i got in all my courses. how is that done
@JuanDVene
@JuanDVene 7 лет назад
I have a problem. The "grade += scoreEntered" doesn't work when I do it. Neither does "grade = grade + scoreEntered". I don't know what I'm doing wrong. My compiler is Dev C++, could that be an issue?
@biomattic9816
@biomattic9816 7 лет назад
make sure that you stated that int grade = 0; and not just int grade; also, yes, your compiler could be the issue
@shadowmeth6583
@shadowmeth6583 7 лет назад
Won't DevC++ initialize all your variables to 0 by default when you declare them?
@ak47em
@ak47em 7 лет назад
is this possible with an if statement inside the loop? i cant make it work...
@npazee
@npazee 9 лет назад
Is it possible to add code after the final while statement? I'm trying to create something which calculates my final term grade based on individual test scores. I extract all the info in the 'do' section and then use a checking command at the end of the 'do' section, somethings like: printf("Is this information correct?"); Then I use scanf too save the string, yes or no. Then in the 'while' section I have: }while (Check == 'No'); /*Grade calculation goes here*/ printf("Your final grade for the first term is 77."); So are we allowed to use 'printf' after the 'while' line? I keep getting an error. If we aren't allowed, how can I rearrange the code to accomodate what I want to do? Thanks.
@MidnightBerries
@MidnightBerries 9 лет назад
Zeeshan Asghar You would just put it in an if statement after the do while loop. }while (scoreEntered != 0); if(scoreEntered==0){ /*Grade calculation goes here*/ printf("Your final grade for the first term is 77."); }
@ventin75
@ventin75 8 лет назад
Bucky, i feel that you can combine grade and scoreEntered as one variable. Actually i still dont understand the advantage of the do... while loop over the while loop in this example. Hope you can convince me what do... while can do but while cant.
@marcoantonio7648
@marcoantonio7648 8 лет назад
+fooser Old, but I'll answer. I think the difference between them it's property of pause. Both creat a input output data system, but"While" runs the programm and you can't stop it. "do... while" you can put "scanf" to creat an manual loop. So the user control de loop, not the computer. If we imagine every pause as a changing of information, we can creat a lot of things.
@ventin75
@ventin75 8 лет назад
+Marco Antonio Graziano de Castro Both are capable of counter and sentinel-controlled repetition.
@marcoantonio7648
@marcoantonio7648 8 лет назад
But the "while" can only run a comander and check the condition, and so go on. "Do while", after make the comander e check the condition, can receive another and different command, and check the condition again. It's manually, and can process information individualy. I'm from Brazil, I'll pass you a link, it's in portuguese, but there's only two images: the first is while, the second one is do while. The words are pretty similar, you can understand. www.ic.unicamp.br/~jpaulo/cursos/mc102/2s2007/aula6.pdf
@billGHH
@billGHH 6 лет назад
Hey just wondering how you do an if else in this to assign for example 90 as highest
@winnieip9851
@winnieip9851 4 года назад
As a beginner in C, pls explain the meaning of float Grade = 0; etc Should it always start at 0 ? thanks
@yehezkielwiradhika6229
@yehezkielwiradhika6229 4 года назад
it means the first value of grade is 0 (before the user inputs the grade), no it depends on how you want your grade value starts.
@chriseljonramos5549
@chriseljonramos5549 9 лет назад
I copied your codes but its not running because of the error in scanf("%f", &scoreEntered);
@FioRazz
@FioRazz 8 лет назад
+Eljon Ramos Space before %f scanf(" %f", &scoreEntered);
@shihaburrahmansamrat9453
@shihaburrahmansamrat9453 6 лет назад
I think this can be done with using just while loop?
@rogerjones9507
@rogerjones9507 9 лет назад
what if a user enters value like 1000 may be its a bug
@asjadsiddiqui7409
@asjadsiddiqui7409 4 года назад
Does printf("Hi") Print out Hi???!??! IM so confused ):
@careanmayne5722
@careanmayne5722 4 года назад
I cant see it at all
@rocknrolla1211
@rocknrolla1211 4 года назад
can someone help me? what does he mean by grade? also grade += scoreEntered; WHAT?!
@DilanthaPerera
@DilanthaPerera 5 лет назад
Cool
@rajakishoremohanty2799
@rajakishoremohanty2799 6 лет назад
nyc video
@totalytaco3715
@totalytaco3715 10 лет назад
Is this series still going?
@unboxmodz8584
@unboxmodz8584 6 лет назад
overflow info: type AAAAAAAAAAAAAAA lol
@andyho4682
@andyho4682 9 лет назад
Do i need to enter some different while statement if say one my test score was 0
@yuval4597
@yuval4597 9 лет назад
Just make them type something else instead, like a number over 100 which isnt possible for you to actually get on a test. like for example make the number 200 and make the condition while(scoreEntered
@hassanalattas8870
@hassanalattas8870 8 лет назад
guys whenever I .build and run. the program it's stopped working I don't know why only in "if" and "loops" it's says : hasanC.exe has stopped working please help
@adomasadam3889
@adomasadam3889 8 лет назад
+Hassan Alattas Have the same problem 1:1 copy from Bucky, program crashes after i need to type first grade :/
@johnnyquid1152
@johnnyquid1152 8 лет назад
Send us your code, maybe you made some small mistake.
@adityasangave8811
@adityasangave8811 5 лет назад
What is mean by grade += scoreentered
@jenishhirpara4178
@jenishhirpara4178 5 лет назад
grade=grade + scoreentered
@Tamim1994
@Tamim1994 7 лет назад
Could anyone tell me why you would pick a certain loop over another one? for example why would you pick a do loop over a while or for loop? thanks!
@biomattic9816
@biomattic9816 7 лет назад
a do loop makes sure your code runs at least once. it is possible for a while loop to not even run the code at all.
@Tamim1994
@Tamim1994 7 лет назад
thanks!
@shadowmeth6583
@shadowmeth6583 7 лет назад
Let's see a practical example. Imagine you are making a program for a school in which each student has to enter their weight. Now you can use both loops. int weight; scanf(" %d", weight); while(weight < 0){ scanf(" %d", weight); } int weight; do{ scanf(" %d", weight); }while(weight < 0); So as you can see do loop is probably more easier to understand and more easy to debug to (at least for me it is).
@NoMfingComment
@NoMfingComment 10 лет назад
Hey I don't know if you'll read this hopefully you do and reply at the least.. but I wanted to ask you can you do some new updated iPhone Development Tutorials with the new iOS 7 And the new Xcode etc and make it more deep into developing An App for the newest iOS 7 well i know iOS 8 will be out soon but for iOS 7 with the latest Xcode please?
@mr.j_krr_80
@mr.j_krr_80 7 лет назад
what have you done now these parents are just gonna know all those dirty little secrets we hide behind those averages.... T_T
@nickrameau938
@nickrameau938 9 лет назад
No comment? FIRST!!
@zerothedrunkard6590
@zerothedrunkard6590 6 лет назад
yo, umm, i was trying out this code, but everytime i enter a number, my PC crashes, can someone run this in their computer and see if it is just cuz my pc i slow int main() { float overall = 0; float entered = 0; float times = 0; float avg = 0; printf("AVERAGE CALULATOR press 0 when complete "); do{ printf("current average: %.2f ", avg); printf("input number: "); scanf("%f", entered); overall += entered; times++; avg = overall / times; }while(entered != 0); return 0; }
@ADITYASINGH-ih2hz
@ADITYASINGH-ih2hz 6 лет назад
Namless Gamez you missed & in 'entered' variable.
@zerothedrunkard6590
@zerothedrunkard6590 6 лет назад
yo u are amazing, thx its always the little, isn't it
@ADITYASINGH-ih2hz
@ADITYASINGH-ih2hz 6 лет назад
Yes !! Enjoy
@meqayim4652
@meqayim4652 6 лет назад
This too
@illeone5433
@illeone5433 6 лет назад
how does it work?
@franciscojoseolivero3409
@franciscojoseolivero3409 7 лет назад
You could do this same program without a do while, and just using a while, is this correct?
@biomattic9816
@biomattic9816 7 лет назад
no. because the grade starts at 0 so your loop wont even start
@yingtang9073
@yingtang9073 7 лет назад
I think you want to say that the scoreEntered starts at 0. We can change while(scoreEntered !=0) to while(scoreEntered!=200), it should be okay to use a while instead of a do while. int main() { float totalScore=0; float numberOfTests=0; float scoreEntered=0; float average=0; printf("If you enter all your scores, press 200. "); while(scoreEntered!=200){ printf("%.0f Test(s) Average:%.2f ", numberOfTests,average); printf("Enter your score:"); scanf(" %f", &scoreEntered); totalScore+=scoreEntered; numberOfTests++; average=totalScore/numberOfTests; } return 0; } I am a newbie. If I am wrong, plz correct me. :)
@jeffsam5495
@jeffsam5495 6 лет назад
totally possible
@cornelxbox25
@cornelxbox25 7 лет назад
I wrote my floats like so: float grade, scoreEntered, numberOfTests, average = 0;
@lowbin
@lowbin 8 лет назад
Why do i need the "Grade" variable? it's works fine without that!
@peterivony9516
@peterivony9516 8 лет назад
+Mehedi Hasan Loban You need it. That's what you use to calculate average, because scoreEntered changes everytime you enter it again.
@lowbin
@lowbin 8 лет назад
+Peter Ivony oh, & '+=' means transfer the value of score varibale to grade varibale?
@peterivony9516
@peterivony9516 8 лет назад
+Mehedi Hasan Loban No, it means that create a new value for avarage, and make that the previous value of avarage plus the scoreEntered's value.
@lowbin
@lowbin 8 лет назад
+Peter Ivony ohhh, thanks man :)
@shadowmeth6583
@shadowmeth6583 7 лет назад
You need to total the value because it's a loop and you can't keep the record of total value without summing it up.
@xaralampostheo
@xaralampostheo 6 лет назад
i thin you can do this without do while , just use if (answer== 0) { } ;
@yourbro806
@yourbro806 2 года назад
Hello Mr. Bucky can you please reduce the advertisement, it is so irritating and only in 5 minutes of video there are 3 advertisement, 16 seconds each,,,
@raghavanv97
@raghavanv97 10 лет назад
hey Bucky zoom in the code u did in c++
@dirasadirasa2499
@dirasadirasa2499 6 лет назад
this program does not make sense , it should have better example
@morskipaskenny
@morskipaskenny 10 лет назад
FIRST! :)
@fazzynone1
@fazzynone1 2 года назад
Complicated
@hachij_
@hachij_ 7 лет назад
This is make sense? let me know guys or any better code let me know #include #include
@biomattic9816
@biomattic9816 7 лет назад
of course its possible, but i just dont see why you would do that.
@guigrillo101
@guigrillo101 10 лет назад
Always the same context at the videos: the basics.. You should do some thing more advanced
@sythanh14
@sythanh14 10 лет назад
I think these are more helpful for rockies plz understand him
@yuval4597
@yuval4597 9 лет назад
I think there's nothing wrong with him helping beginners like myself.
@lukedavoli2868
@lukedavoli2868 9 лет назад
apologies for not being masters of code like you. Bucky's videos are great for people like me.
@Treebark1313
@Treebark1313 9 лет назад
guigrillo101 Perhaps you should be suggesting he make a video on the basics of English rather than advanced programming, it'd do you quite a bit of good.
@zerothedrunkard6590
@zerothedrunkard6590 6 лет назад
treebark 10/10
Далее
C Programming Tutorial - 27 - for Loop
5:20
Просмотров 292 тыс.
ОБЗОР ПОДАРКОВ 🎁 | WICSUR #shorts
00:55
C Programming Tutorial - 42 - Pointers
9:56
Просмотров 435 тыс.
Stupid C Tricks: Unsafe Functions You MUST Avoid!
9:26
#18 While vs For Loop | Which to use and When?
6:58
Просмотров 86 тыс.
C++ for loops explained 🔂
3:39
Просмотров 11 тыс.
C Programming Tutorial - 25 - while Loops
8:29
Просмотров 260 тыс.
C do while loop 🤸‍♂️
3:24
Просмотров 53 тыс.