Dude, I swear you have a way of teaching C++ so simply and understandable! I take 45 mins of CS class and I'm still left in confusion on certain topics, thank you so much for investing your time to do these tutorials!
@beri41387 жыл бұрын
Just curious but does learning C++ help with CS?
@lich.possum4 жыл бұрын
@@beri4138 the idea is that if you can learn c++ the lowest level language you can learn higher level languages
@Hvidbergen4 жыл бұрын
@@lich.possum where do you get that idea from? And what do you mean by "lowest level language"?
@samirgunic9 жыл бұрын
Just to clarify one thing: the "sentinel" is the "-1" value itself. It's called a sentinel value. It's a special value that controls when to terminate a program, or as in this example: when to step out of the loop. It just so happens that in this example the program ends once he steps out of the loop. But other programs could do other things after this. Hence, "sentinel controlled program". It's not a program controlled by a certain Sci-Fi character if you know what I mean! ;-)
@GizziMoD8 жыл бұрын
+Samir Gunic thx.. I was wondering just this! :)
@nerdii18423 жыл бұрын
oh cool, thanks for explaining that.
@hetaeramancer2 жыл бұрын
sentinel vs scourge yun pare
@hetaeramancer2 жыл бұрын
" a program controlled by a certain Sci-Fi character if you know what I mean! ;-) " dude, seriously? a sentinel controlled program is when a sentinel value controls it. quit messing around and talking about sci-fi characters bro. not cool
@samirgunic2 жыл бұрын
@@hetaeramancer no way?! You need to get a sense of humor. Relax, we are not in school here.
@RCTestKid9 жыл бұрын
Woot. Have watched 20 of your C++ tutorials in 2 days! Aiming to watch 10 a day until I have finished your series!
@lastofthestars64817 жыл бұрын
Really ??
@reshavraj40904 жыл бұрын
Mee to @zak
@RCTestKid4 жыл бұрын
@@reshavraj4090 Awesome! (yes I did finish the series)
@reshavraj40904 жыл бұрын
@@RCTestKid Any suggestions..for data str and algo.!!
@RCTestKid4 жыл бұрын
@@reshavraj4090 Sorry, I don't know what you're asking.
@widowdev6 жыл бұрын
Hey Man. I know this was posted in 2011, and I don't even know if you are active on this channel or not.. but this is really enjoyable to watch. I am taking a condensed 6 week online C++ class at Penn State and yes the book we use is extremely good, but having you think through an example and explain everything is really helpful. I don't have a professor doing that like I normally would in a class like this, all I have is worked out examples in the book - so this gives me that feeling of having a professor to teach me it. Thanks a lot man, appreciate this.
@chrismavian619411 жыл бұрын
I like how he makes everything sound so easy. Something to definitely work towards.
@RoxusRemo8 жыл бұрын
guys keep clicking onto each concurrent video every second and you get a really cool mix of "hows it goin guys"
@zeustheboerboel37948 жыл бұрын
ads!!
@Ele200028 жыл бұрын
adblock!!
@hbv85608 жыл бұрын
Don't use adblock on his vids, this is his income...
@felixruiter33542 жыл бұрын
This was much more entertaining than I thought it'd be
@onelerv113 жыл бұрын
I wish I could subscribe more then once to this channel.. I'm so grateful to bucky, he's taking up his own time to help out with teaching us.. Thanks man I really appreciate all your help!
@muhdsafwan4018 жыл бұрын
cout
@kiva89867 жыл бұрын
#include using namespace std: main() { int myAge; cin >> myAge; if (myAge > 1) { cout
@zakariaosman64876 жыл бұрын
its using namespace std; and int main()
@yaboi37495 жыл бұрын
*RETURN 0;*
@grossio55645 жыл бұрын
@@yaboi3749 yeah you are right........ YA BOI
@sicklaxplayaz13 жыл бұрын
I've noticed a great way to test if you actually learned anything from Bucky's tutorial. Always try to make a program similar to the one that you just made in the tutorial, if you are struggling, go back and watch the tutorial again. This has worked for me, and i just wanted to share it with you.
@WhosTheBossHD9 жыл бұрын
Here's a common practice every coder MUST know. Whenever, you have a variable as your denominator, it is a good idea to make sure that your variable is not 0 (Zero)
@Nightcrawler90019 жыл бұрын
WhosTheBossHD but if he didn't make total age 0 than it would've been null and u cant add to null
@abird359 жыл бұрын
+KomodoPanther what he means is that he should've probably added an if (NumberOfPeopleEntered != 0) statement over cout
@CaliforniaGuys9169 жыл бұрын
This is a very good tip, and I actually ran into this problem while I was in class and couldn't figure out what was going on.
@hetaeramancer3 жыл бұрын
how the hell could it be 0 though? idiot...
@user-vv9fw7ok9d3 жыл бұрын
@@hetaeramancer Understand what he is saying before insulting him! In case the first input is -1 then the program terminates with numberOfPeopleEntered = 0. Now I wonder who is the idiot...
@DeejayAlid8 жыл бұрын
Nice tutorial, it would have been great if you gave us exercises at the end of each video, thanks for the tutorials.
@theseangle4 жыл бұрын
@Sourin 2 🤦♂️
@NA-is2oo7 жыл бұрын
your 360p quality recorder is actually so satisfying like everytime i switch back to the video after i finished a line of code you demonstrated. im actually happy
@shyamsrinivassportive91822 жыл бұрын
Man, what are you? You are teaching way more better than many paid tutors. You deserve more than this
@TakingItCasual13 жыл бұрын
I was tinkering with the last tutorial and made something that allowed the user to decide how many numbers they wanted involved, but this looks like it gives more options. Time wasted, lessons learned. Love your videos!
@carlgauss88798 жыл бұрын
And on Bucky's 20th tutorial, I finally found out about AD Block Plus for KZbin's beyond obnoxious amount of ads. Life is beyond amazing.
@Skorbeen9 жыл бұрын
Bucky, you promised at least 1 bad joke per video. You did this many videos back. I think you are russian your videos. On a more serious note, thank you so much man. I've been trying to find a good source to get into programming, you explain things very clear and I'm amazed with what I've built in just a couple of days with your help. Looking forward to watching the rest of your videos:) Cheers!
@miguelmartinez1607 Жыл бұрын
11 Years Later and still the best tutorials! Thank you! Also would have taken this opportunity to teach ageTotal+=age; instead of ageTotal = ageTotal +age;
@SetYourHandle39 жыл бұрын
I love all your work Bucky. Thank you for making these tutorials :).
@emmanuelhjg6913 жыл бұрын
When you declare your variables, always set it to 0 because it can get random values if you don't
@constantinmanea54813 жыл бұрын
I really like this guy!! He convinced me to start learning C++ The first video in the list when he say`s Hello "C-nts" killed me I was like , yeah this is where i need to start :)) very well explained, good examples and straightforward!
@TheCosmicChicken12 жыл бұрын
"And you need to...watch more'v of my videos or something, I dunno'." Quite the sales pitch there, Bucky!
@blazingredgaming737711 жыл бұрын
int numberOfPeopleEntered can be shortened to int nope
@george18almonte6 жыл бұрын
I put numberOPE
@coows6 жыл бұрын
You mean string numberOfPeopleEntered = "nope" Because you can put words into int, but it's better to put it into a boolean or a string. Really, it's that simple. Try subtracting int "1" and boolean "1" and it wont work. (boolean for short is bo)
@nomevic9 жыл бұрын
to make sure that the program don't goes crazy if the first number you enter is -1, throw there an If statement too: int main() { int age; int ageTotal = 0; int nrOfPpl = 0; cout age; while(age != -1){ //this make the program stop when -1 is entered ageTotal += age; nrOfPpl++; cout age; } cout
@MoNeyAssasin8 жыл бұрын
why ageTotal += age instead of ageTotal + age?
@matthewnaylor58948 жыл бұрын
ageTotal = ageTotal + age; is the same as: ageTotal += age;
@saurabhs47437 жыл бұрын
Victor Popescu if is by default check Ed in while loop. it's a while loop not do while :)
@xTxNarutoxTx12 жыл бұрын
I've rarely seen ads, if any at all on his videos o.o. I hope he does make money from these, he definitely deserves a lot. I bet people are passing computer science like nothing because of Bucky. If he is a millionaire he deserves it :D.
@dibbiepk12 жыл бұрын
After watching this video, I made some common mistakes when I tried it, heres my 2 mistakes I made: int number; - I didnt add = 0; cout >> "Enter first persons age or -1 to quit"
@PapoochCZ11 жыл бұрын
You can set a new variable to any number if you're about to do calculations with it immediately. If you're gonna assign a value to it later, (e.g. via keyboard input) you can just declare it -> allocate a space in the memory for that variable but it won't have any specific value. (if you try to call it, bad things can happen)
@rohithaider6 жыл бұрын
Best tutorials ever! I love the way you Mr. BUCKY!
@NALDstudio11 жыл бұрын
Somewhere in the code, (line 22), we can notice that we divide the variable ageTotal by numberOfPeopleEntered. This means that if you type -1 immediately when the program launches, the numberOfPeopleEntered still contains the value of 0 as it is the default value. By realising that the fact dividing any number by 0 causes an equation that doesn't exist, it's simple to understand why the program crashes. By putting a condition that numberOfPeopleEntered must be different from 0, we're okay. :)
@v1e2ridisQ3u4o12 жыл бұрын
Yes, you can do it that way too. Though, as Bucky mentioned in an earlier tutorial, doubles take up more bytes than an integer, because it's more precise. So in a more complex program where you mainly work with integers but have one or two print-outs or returns which requires decimal precision, a typecast could be a good solution.
@NALDstudio11 жыл бұрын
None of our suggestions is wrong actually. Both are very simple to type and to understand.
@d3lt4X5 жыл бұрын
Using your code, if you type -1 to quit when it asks you to set the first age, it's not going to work as expected. ageTotal and numberOfPersonEntered will be 0 because we've never entered the loop 0 divided by 0 = crash
@UrAdversary5 жыл бұрын
who cares? you're quitting the program...
@markandrewmoran43983 жыл бұрын
Sir i can't thank you enough fir making C++ learning easy, and I hope you continue to help people who wants to become a good programmer like you. Btw What App do you use for programming,
@LuharVasGamingOz12 жыл бұрын
Yeah it can be a bit confusing, i suggest getting a book about the basics of C++, before i started watching bucky's videos i read a book about C++ and it's history and it was all so clear to me :)
@Kats0723078 жыл бұрын
4:07 How can I type just the first few letters and make the POSSIBLE variables be displayed ? In this case it was the huge variable numberOfPeopleEntered :-) I'm also using CodeBlocks on a Macbook
@JackMcCrackenOtt13 жыл бұрын
Bug: entering negative 1 for the first value causes division by zero (0/0) because both ageTotal and numberOfPeopleEntered are initialized to zero. You could fix it by making a if statement after the first cin read testing if the age variable is equal to -1 and simply returning zero if so.
@williamgrove96178 жыл бұрын
I think at this point it would be good to cover error handling! Especially when working with inputs!
@dibbiepk11 жыл бұрын
Holy crap this is gon be a big bonus for me next week... Thanks Bucky
@vulpine6785 жыл бұрын
thank u so much... the explanation is clear and straightforward...
@jigarlush64299 жыл бұрын
bucky so great bro you are tutorial it's make me fun i mean i got you more than my lecture
@AdpoGamer11 жыл бұрын
Thank you so much for this tutorial! It has helped me a lot :D
@leo-rq2ei8 жыл бұрын
while(theNewBoston == good tutorials){ cout
@1kalekip18 жыл бұрын
Leandro Im gettng a parse error. Pls help!
@leo-rq2ei8 жыл бұрын
+Kale Kip you have to create 2 variables: int theNewBoston =100; int goodTutorials =100; while(theNewBoston == goodTutorials){ cout
@1kalekip18 жыл бұрын
Leandro :)
@sophieeeee38 жыл бұрын
You crashed my command prompt goddammit.
@coows6 жыл бұрын
Upgrade your computer to a dual core
@muhammadhadad81857 жыл бұрын
Amazing! Love your lecture sir!
@v1e2ridisQ3u4o12 жыл бұрын
Yes, you can do it the other way around too to round decimal point types like floats and doubles to integers by putting (int) before the variable.
@NALDstudio12 жыл бұрын
To solve the -1 problem, you need to add a if condition before dividing by the number of people. As numberOfPeopleEntered = 0 when you type -1 at the begenning, it causes a division by 0, which is impossible. if(numberOfPeopleEntered != 0){ cout
@sriramiyer750411 жыл бұрын
the program will never end
@mockingbird38097 жыл бұрын
In this program first itself is we entered -1 means the code blocks will hang, cheak it out with same command that Bucky shown
@RedsBoneStuff9 жыл бұрын
2:34 Or "nope" in short :3
@TheProjekton10 жыл бұрын
nPeople It's known throughout programming that using "n" means "number of".. nPeople = numberOfPeople nRedApples = numberOfRedApples etc etc
@metznimbo2913 жыл бұрын
@Starcraft2Rogue he will be doing that, he said in the description of his last "Buckys C++ Tutorials" series(#73)
@chrismavian619411 жыл бұрын
No. The number of people entered is how many people you are including in your loop. The age total++ is adding the actual age each time a new person is introduced to your loop. Hope that helps.
@dhruvkhetrapal42799 жыл бұрын
We could just take input from user for the no of persons.Then accordingly run the loop.
@v1e2ridisQ3u4o12 жыл бұрын
You do get a rounding error with this, for example putting 10 and 11 you should get the average 10.5, however it outputs 10. Putting a (float) before ageTotal/numberOfPeopleEntered; you get a few decimals
@Moon_Rose달장미4 жыл бұрын
highlights: 1. ik i spelt it wrong. big deal, who cares 2. enter big numbers like 86, 68, 5 and yeah all those. like 5's a big number (,duh!)
@MarijnKonings11 жыл бұрын
No idea, a double or a float would indeed be better in this case for the result. The amount of people entered wouldn't really need a decimal number since it will always increment by 1.
@ThePhil65212 жыл бұрын
at the beginning ageTotal shout be = to 1 because when you want to quit you enter -1 if you ad cout
@Qazqi11 жыл бұрын
Dividing by 0 is undefined behaviour; it doesn't have to crash.
@commentor56248 жыл бұрын
Instead of using ageTotal=ageTotal+age, you can use the compound operator ageTotal+=age.
@NikorasuChan12 жыл бұрын
I learnt few programming languages beforehand ;) && is means 'and', for example if there two variable, and you want to check whether both variables is equal to the value you want, and if both returns the value that you want, for example, you wanted variable a to return 1 and b to return 0, by using if (a==1 && b==0), you can then put in the code in the { } and blah blah blah... eventhough I dont know if I'm answering you XD
@samirgunic8 жыл бұрын
9:29 Could this explain why you named your project Watermelon? ;-)
@NoName-oq8ok8 жыл бұрын
thaaaaaaaaaaaaaaaaaaaaaaaanks finally i got it
@george18almonte6 жыл бұрын
I literally love you dude
@bbszn11 жыл бұрын
To get exact average, he would need to do ageTotal from "int" to double or float. And, I think, he would need to do "Average age"(line 22) an variable, which type would be double or float. Then he would get an exact average.
@Qazqi11 жыл бұрын
0/0 is indeterminate. Positive or negative numbers divided by 0 are undefined.
@breenud39tv4 жыл бұрын
I have a question, I tried entering 10000000000 just as a joke to see what would happen then it infinitely loops what I had in cout. How do I prevent that? Like how would I add a limit for age lets say so no one is allowed to enter such high numbers?
@samirgunic9 жыл бұрын
7:35 Nope! It says "is 10 not equal to -1" and the answer is "yes". Yes, 10 is indeed "not equal" to -1. The code will run, it will not... not run.
@odo43211 жыл бұрын
Modified this program using only what we have learned to get number of people, total age of people, oldest person, youngest person, and average age of people entered.
@LuharVasGamingOz12 жыл бұрын
They are integer values so no they don't have to be positive. As long as they are whole numbers (meaning that they do not contain decimals) it should be fine :)
@dibbiepk11 жыл бұрын
Thats because when the program first starts, the user hasnt entered anyone yet, so after they enter someone that value will be 1, and when they enter the next person it will be 2, and so on and so on, but it starts at 0, because they didnt enter any one yet, so its value is 0
@mjsanchez21738 жыл бұрын
Buckey, What if the user enters -2 or -3, then the ageTotal will be decremented by 2 or 3. Is that what you want to do ?
@denisotim76408 жыл бұрын
Hey, I'm not Buckey but that's not what he intended. Simple just assume the users will stuff up your program. So... apply some additional 'if' statements to avoid any unnecessary bugs. #include // #include int main() { int age; int age_total = 0; int total_members = 0; double average = 0.0; std::cout
@NeilRoy10 жыл бұрын
So if I enter -1 right away without entering any ages at all, what happens? You should always check for errors, test everything, make certain number of people entered and the total ages are both positive values. You should also check for proper values when they are input, perhaps in a range from 1 - 120. Get in the habit of checking all return values and testing everything.
@joelsanchez32506 жыл бұрын
Bucky is a great speller !!!! "Number of peoople eneted !!!! "
@xetrius36719 жыл бұрын
You didn't account for the user wanting to quit before entering an age. For those who got an error because they entered -1 before entering an age, you can solve this with a simple test to check if the amount of ages entered is bigger then 0. For example: #include using namespace std; int main() { int age; int ageTotal = 0; int people = 0; cout age; while(age!=-1){ ageTotal += age; people++; cout age; } if(people != 0){ cout
@niceheadcrab3422512 жыл бұрын
You can divide by zero. A positive number divided by zero is infinity; a negative is negative infinity. I forgot what zero divided by zero was.
@intensity6713 жыл бұрын
Hey Bucky, sorry for this annoying interruption for a little bug but you forgot that if the user puts only 1 age in this program it'll cause wrong output i in the computation of age and number of people... the onlyway to fix this is to put the numberofPeopleEntered++ above the loop also...
@user237248 жыл бұрын
A more efficient way of doing it: #include using namespace std; int main() { int age = 0; int pCount = 0; int totAge = 0; int avAge = 0; while (age != -1) { cout > age; totAge = totAge + age; pCount++; } avAge = totAge / pCount; cout
@fangxd94517 жыл бұрын
Thank you, good sir.
@JoshRenton9111 жыл бұрын
If you use numbers that don't average to integers it doesn't give you the decimal. When do we learn about floating points? Cheers, your videos are awesome
@P4INKiller12 жыл бұрын
Yup, anytime you specify one type of data as another datatype.
@dkblade2711 жыл бұрын
Bucky forgot to type cast the average part. Int divided by int only gives int but the average can be a decimal value. So remember to type cast.
@TheUntamedNetwork11 жыл бұрын
hey, i didnt want it to attempt to work out averages if you quit immediately so before the the loop i added a if (age==-1){return 0} in this example it works perfect but i was wondering if it would trip me up on bigger projects?
@imamuddin80424 жыл бұрын
You could start with age = 0 and take your first cout and cin inside the loop. And with that, you dont need to put again cin >> age at the end of loop.
@imamuddin80424 жыл бұрын
Sorry my bad, in that case, first iteration of loop would always happen and it might take invalid -1 as input and will return invalid average -1
@MrEpicSpace10 жыл бұрын
type -1 on first input and it should crash.
@AntiAnathema10 жыл бұрын
Because at the end of the programme it is still trying to divide by 0.
@berrymckokinger93177 жыл бұрын
If you entered -1 on first input,the output would be the two cout statements......smh
What about this one: (I know it's a different subject.) #include using namespace std; int main() { int classnumber; int x=1; int number; int total=0; cout > classnumber; cout
@leaper78085 жыл бұрын
You can fix that by doing a pre-check. if (numPeople == 0 && age == -1) { return 0; } This way the program will exit safely without a crash.
@pragatiranjan94183 жыл бұрын
in my program no.of pepole entered is always showing the actual value increased by one
@yagamilul44794 жыл бұрын
i just love the number 5
@NikorasuChan12 жыл бұрын
I fixed it by checking the last two code using if(ageTotal>-1 && numberPpl > 0){//the last two codes before return 0;} I fixed the problem, but there may be other way to fix it... but I'm pretty sure this works XD
@MrZiglu9 жыл бұрын
so we are not having the first person age in a while loop, because we just want to write that is first one? and the first incremenation and ageTotal +=age is connected with that cin above the loop :) ?
@BiscuitTech12 жыл бұрын
@kojax98 That's because one of "Age" has a capital letter and the other hasn't. Make them both identical and it's gonna work.
@NALDstudio11 жыл бұрын
Also, I was trying to show the source of the problem inside the code, which was caused by the division by zero so my example was better to explain the solution to that problem.
@Owlserker7 жыл бұрын
When i type -1 to get the average when i open the .exe after putting in some numbers the console closes. how do i say no to that?
@makegamestv2479 жыл бұрын
In what case would you prefer to use a sentinel value over... say a string input like "quit"? I haven't followed your other tutorials, so you may have already covered this.
@makegamestv2479 жыл бұрын
+Peterolen Yes. I was under the assumption a sentinel "value" had to be a number. Since then I learned that's not the case.
@baqerghezi13424 жыл бұрын
you don't need to initialize the variables if you use (do - while) loop
@edwarlkd81412 жыл бұрын
If we want to make the function the other way, would it better to use Void function or Value returning funcition? Value returning funciton as in like make it as separate function outside the main?
@arturbella254411 жыл бұрын
I'm the rainmaker, i'm closing all the loops.
@dre38w13 жыл бұрын
@Rigardoful haha That works too. Making the numOfPeeps an unsigned int works a LOT better than my order of operations take on it.
@TheWeirdTechGuy13 жыл бұрын
@colouredmirrorball That's quite difficult because the user's input could be either a number or a letter, so it would need 2 different types of variable. Read about data validation.
@Impulse_Photography8 ай бұрын
I think, you should have use zero instead of (-1) to cause the loop to quit. Otherwise, if someone entered zero then it will do the division by zero, which could cause program to crash.
@PipleKlo7 жыл бұрын
Can't you add cout
@NA-is2oo7 жыл бұрын
dood so at like 5:26 you mistyped it right i was typing fast and typed the exact same thing your wrote *peoople eneted*
@mohammadashhar39168 жыл бұрын
when we enter int agetotal= 0; and int numberofpeopleentered= 0; How does the Program know which one is total and which one is number of people entered?
@Binary1010011 жыл бұрын
That's because they're ints. If you wanter higher numbers, use longs.
@creativeknowledgemike23378 жыл бұрын
I did something wrong , i think i hit a wrong button now past calculations are showing on too these new ones. not sure whats going on.