Buckys C++ Programming Tutorials - 21 - Assignment and Increment Operators

  Рет қаралды 390,039

thenewboston

thenewboston

Күн бұрын

Пікірлер: 185
@mrAspDotNet
@mrAspDotNet 11 жыл бұрын
x++ increments the value of variable x after processing the current statement. ++x increments the value of variable x before processing the current statement.
@jakethesnek1443
@jakethesnek1443 11 жыл бұрын
Bucky is my hero. I'm 2 Weeks into my intro to C++ class and I've already learned everything we will cover in 10 weeks.
@Remychels
@Remychels 10 жыл бұрын
Bucky you rock! Best C++ teacher yet.
@umarbekinalkar2314
@umarbekinalkar2314 2 жыл бұрын
still best c++ tutorial in 2021
@ValdiBald
@ValdiBald 10 жыл бұрын
Awesome tutorials Bucky! One point, "++" is a function with a return. So when you do x++ your calling a function that increments x but the "post++ function" is designed to return the old value in case you need it (in most cases you don't). If you do the "++pre function" your calling another function that also increments but returns the new value. That's why your getting 20 because your not asking for x, your asking for the return of the function. It does increment before the end of the line and you can see that e.g. if you do: cout
@UncannyAura
@UncannyAura 10 жыл бұрын
...It helps and simple...I suppose but it's too long an explanation, its irritating. Doing x++ is like telling the computer to increment the value of x after the line of code. Doing ++x is telling the computer to increment the value of x before the line of code. The End.
@ValdiBald
@ValdiBald 10 жыл бұрын
Uncanny Aura Your right, its way too long. One thing, in both cases it increments x before the line ends. That's my over complicated point. What I'm trying to say is that the new value of x and the return of the ++ function are two totally different things. Hope it helps :)
@UncannyAura
@UncannyAura 10 жыл бұрын
ValdiBald Ok, much better :)
@arandomboredindividual7855
@arandomboredindividual7855 3 жыл бұрын
still the best c++ tutorial on youtube and its 2021
@srijal
@srijal 10 жыл бұрын
No of viewers decreases as we progress to each tutorial.
@ClaudiuB
@ClaudiuB 7 жыл бұрын
cuz they're Fat::Lazy(time, age, weight, country, motivation)
@Mystosia
@Mystosia 7 жыл бұрын
nah they are straight up Boring::Lazy(time, age, intelligence, motivation)
@zapxcero
@zapxcero 6 жыл бұрын
r/iamverysmart
@arandomdude1741
@arandomdude1741 6 жыл бұрын
It decreases because people just give up to continue.
@ankursingh8296
@ankursingh8296 6 жыл бұрын
True. agree with it
@ShadowTetsuo9999
@ShadowTetsuo9999 11 жыл бұрын
im actually glad i came across your comment,lol I am trying to learn C++ and i was about to wait until i got to lesson 30 then spend about a week reading the book then come back and see if i grasp more of what Bucky is teaching, so far i love these tutorials, he explains very well
@reziyemusulaiman9323
@reziyemusulaiman9323 3 жыл бұрын
omg, this guy literally teaches everything in so simple and clear way, thanks bucky
@SlightlyNerdyGaming
@SlightlyNerdyGaming 11 жыл бұрын
Finally, Bucky taught me something that the comments taught me 3 videos ago. (Talking about the '+=' thing.)
@NeilRoy
@NeilRoy 10 жыл бұрын
Actually, C++ will follow the line and execute each statement as it goes. ++ is actually a command that would get interpreted as a machine language instruction like INC (increment). So if you read through the line again... you may understand why it prints out the unincremented value first with x++. This is what the compiler sees... cout
@SebSharma
@SebSharma 7 жыл бұрын
Sorry guys, I had too #include using namespace std; int main() { int a = 1; int num = 0; while(a==1){ cout
@unison1978
@unison1978 9 жыл бұрын
these are the details that matter when learning programming... Brilliant!
@michaelC2585
@michaelC2585 13 жыл бұрын
@iYateszy no. it must be after to tell the comp. that it needs to increment by one. you could do that if you had a variable called '++x'
@blade55555
@blade55555 12 жыл бұрын
Agreed. When I was younger about 6 years ago or so (about 13-14) I tried to teach myself C++ and didn't really understand it. I am now 20 and I am understanding this unlike my younger self. Kinda crazy because I just wanted to jump straight into game programming which now that I know how it works a bit more, is a long way off ^^.
@_sideways_6321
@_sideways_6321 5 жыл бұрын
You teach way better than my lecturer THANK YOU FOR EXISTING
@dave369_
@dave369_ Жыл бұрын
Great explanation of pre and post increment operators 👍👍🙂🙂
@voidarts1176
@voidarts1176 6 жыл бұрын
Bucky, you will always be a double plus in my books!
@toringedotno
@toringedotno 12 жыл бұрын
@Regginyaga It because of UNIX systsems, 0 means the program quitted without errors. Numbers above 0 have their own error code.
@JohnMcclaned
@JohnMcclaned 11 жыл бұрын
I have watched all these videos in like a day, with no previous experience and understand basically all of it. I guess it just comes down to practicing what I have learned and experimenting different things :) GET EXCITED! One step closer to world domination
@arthureru
@arthureru 11 жыл бұрын
x++ uses the old value in the statement that it was used after the statement it increments ++x increments the variable before running the statement cout
@RedsBoneStuff
@RedsBoneStuff 9 жыл бұрын
4:14 Prints "21" twice. _And_ this is episode 21. _And_ 21 is my favourite number. What are the chances ...
@bocbinsgames6745
@bocbinsgames6745 9 жыл бұрын
RedsBoneStuff hate to say it but the program is not using any random operators so the chances were 100% that it would be printed. sorry if i ruined your miracle.
@RedsBoneStuff
@RedsBoneStuff 9 жыл бұрын
TeamGBplaysminecraft Yes, I know all of that ... but Bucky chose 20 "randomly" because any number would be fine. He did not, however, know that 21 is my favourite number. And I'm pretty sure he didn't intentionaly link this with the number of the episode.
@bocbinsgames6745
@bocbinsgames6745 9 жыл бұрын
ok true
@PS2Damon
@PS2Damon 9 жыл бұрын
RedsBoneStuff he didn't pick 20 randomly, he said that it was his favorite number..
@mishoaleksidze7820
@mishoaleksidze7820 9 жыл бұрын
+RedsBoneStuff So, do you think you're special?
@Elcosmicstar1
@Elcosmicstar1 6 жыл бұрын
Hi Bucky, thank you for tutorials. I accidentally noticed while doing a lesson that if I leave out "int" at the beginning of "main" the program will still run, so I tried it with a few others and it stilled worked. I also observed that if I replaced "int" with "void" or any others, I would get the error message "main must return int". I guess, because main must return an int, it is also not necessary to declare it. "pretty cool huh".
@vagabon5130
@vagabon5130 5 жыл бұрын
wow your very clear in your speaking. thx much.
@blade55555
@blade55555 12 жыл бұрын
lol I didn't even think about that. I just now noticed how much it dropped from the first couple xD.
@buddyd2841
@buddyd2841 8 жыл бұрын
The
@ryndm
@ryndm 9 жыл бұрын
Your amazing ur videos help me a lot
@Skulltroxx
@Skulltroxx 5 жыл бұрын
3:14 lmao i died XD //notice the timestamp (pie)
@murphydublin
@murphydublin 9 жыл бұрын
Thank you brother, your so genius.
@josephlong169
@josephlong169 9 жыл бұрын
I made the mistake attempting to go though your Java tutorials before coming here...
@Stavros33GR1
@Stavros33GR1 3 жыл бұрын
is still your favorite number 20???
@sounakghosh8874
@sounakghosh8874 2 жыл бұрын
i remember this part.. another tutorial used like 21 minutes to explain this simple thing
@thered_hood7451
@thered_hood7451 7 жыл бұрын
best tutor ever
@cj_kreates
@cj_kreates 2 жыл бұрын
Whose here 2022
@masterhadi77
@masterhadi77 11 жыл бұрын
ok but i dont get this; you already defined the variable x as 20. so cout
@Telseilong
@Telseilong 13 жыл бұрын
i still would put return 0; looks like codeblocks holding your hand, which is good but other compilers could give you a WTF a int function not returning a int.
@youngGenzombie
@youngGenzombie 11 жыл бұрын
That comment actually makes me feel good about myself :D
@gabriellelopez-herrera820
@gabriellelopez-herrera820 5 жыл бұрын
You are awesome!
@loading_wait
@loading_wait 9 жыл бұрын
was it only me who giggled every time he said "twenny won"
@dibbiepk
@dibbiepk 12 жыл бұрын
Assignment operators, Assignment operators, Assignmentoperators, got it! :P
@bryanswaggbeast8194
@bryanswaggbeast8194 8 жыл бұрын
so i believe C++ stands for #1 coding language i guess!?
@NickSecourity
@NickSecourity 10 жыл бұрын
You are a very good teacher :D....
@steve122288
@steve122288 8 жыл бұрын
if you can do "cout
@steve122288
@steve122288 8 жыл бұрын
interesting. I thought ++ was a shortcut for +=1 though so i would not imagine it to have higher precedence. It is still slightly strange that 20+x results in 30 where ++x is some kind of special operator to.. add a number to x? .. but it intentionally has a higher precedence? Well, i think the designer of c++ is playing a role here. Also i find it very funny that you can type 30; as one line haha. never knew this was ok it makes me rethink how a programming language works.
@steve122288
@steve122288 8 жыл бұрын
also I noticed in java it does not obey precedence with ehm math operands? I mean like 18 + 2 * 2 = 40 in java and other languages but in c++ it is like real math where 18 + 2 * 2 = 22 . I guess java doesnt have the
@herp_derpingson
@herp_derpingson 12 жыл бұрын
Dont question my persistence! I went through all the 200 android tutorial videos :D
@huskie5279
@huskie5279 9 жыл бұрын
Thanks Bucky!
@victornnah3920
@victornnah3920 6 жыл бұрын
Why does bucky not have any new videos or posts on any of his social media?
@digitalhustler05
@digitalhustler05 9 жыл бұрын
thank you bucky too
@Direwolf56
@Direwolf56 11 жыл бұрын
It's not programming itself, its the programs you create.
@SamGulz
@SamGulz 11 жыл бұрын
Proud of myself for d first time
@umaribnali2138
@umaribnali2138 10 жыл бұрын
Thanks a lot man! A big (Y).
@keepingalowprofile
@keepingalowprofile 12 жыл бұрын
%= is pretty mind blow
@baddmanaz
@baddmanaz 10 жыл бұрын
thanks, OBOEma!
@Ukid111
@Ukid111 9 жыл бұрын
Can you use modulus (%=) for an increment operator?
@Ukid111
@Ukid111 8 жыл бұрын
+Peterolen Ty
@TheCosmicChicken
@TheCosmicChicken 12 жыл бұрын
Just breathe, Bucky, breathe.
@Erox006
@Erox006 12 жыл бұрын
how many favorite numbers do u have bucky ??
@xXLanyuzAnlunXx
@xXLanyuzAnlunXx 8 жыл бұрын
can you do ++x++ :)
@xXLanyuzAnlunXx
@xXLanyuzAnlunXx 8 жыл бұрын
oh lol
@steve122288
@steve122288 8 жыл бұрын
+Phloat Wireless yeah it gives me an error when i try that.. is there actually a way to do it? maybe its the standard that is preventing me in some relation to what peterolen was saying
@steve122288
@steve122288 8 жыл бұрын
error: 1value required as increment operand. That is what it tells me no matter where i place it. Good thing I would never have to do such a thing anyway haha.
@joeygylytiuk3376
@joeygylytiuk3376 5 жыл бұрын
well technically that'd be the same as incrementing "x" by 2, right? so same as{ cout
@supbrotv
@supbrotv 12 жыл бұрын
WATERMELON!!
@Kyle-ob7us
@Kyle-ob7us 11 жыл бұрын
did you not watch the last video? I think you should go back and watch it again if you didnt see the math.
@sherifnegm9046
@sherifnegm9046 10 жыл бұрын
good job
@ishaanpunetha
@ishaanpunetha 3 жыл бұрын
Okay thanks
@asian_delirium
@asian_delirium 8 жыл бұрын
I am totally new to this language and i have a weird problem here:just testing around when i find out that when i try this simple code: #include using namespace std;int main() { int x = 11; while(x>=0) { cout
@kuraigu12
@kuraigu12 8 жыл бұрын
+zzZMrWangZzz Save the project and relaunch the Code::Blocks. I've encountered these problems many times before I switched to Visual Studio.
@luksports555
@luksports555 11 жыл бұрын
Wait, is there (varible)** or **(varible)?
@TraceursMonkey
@TraceursMonkey 6 жыл бұрын
Finally , someone who dose not haw an accent
@mrAspDotNet
@mrAspDotNet 11 жыл бұрын
GJ!
@Capn-Coin
@Capn-Coin 8 жыл бұрын
Anyone have any idea why my program takes long to build and run?? its not the code because i've tried running just a hello world program... its starting to annoy me because it takes about 5 - 10 seconds to build and run each time I want to check my code...
@Capn-Coin
@Capn-Coin 8 жыл бұрын
+Peterolen yeah it was. thanks :)
@SamanGivian
@SamanGivian 8 жыл бұрын
that happens to my visual studio too
@TheDarksiderrr
@TheDarksiderrr 11 жыл бұрын
That's just what he said ;)
@ClaudiuB
@ClaudiuB 7 жыл бұрын
"I'm 14 and cthuluhuh" "You're better than my teacher! f.him!" "did I spell anything wrong, yes who cares?42" ++++++++++++++++++++++++++++++
@supTE
@supTE 5 жыл бұрын
Nice
@markanthonybulaon4113
@markanthonybulaon4113 11 жыл бұрын
aklncasc: Buck Rules... \m/ you Buck my World \m/
@avnisharma4902
@avnisharma4902 10 жыл бұрын
thanks
@glenngroveau1807
@glenngroveau1807 10 жыл бұрын
5 Tutorial Jul kkk99.oo
@That0n3Gam3r
@That0n3Gam3r 11 жыл бұрын
if the endl at the end of cout doesnt work for you then do this cout
@NDZ12345
@NDZ12345 13 жыл бұрын
good video
@mathewseldo5774
@mathewseldo5774 10 жыл бұрын
bucky ur vids r cool
@TheJavaScriptKid
@TheJavaScriptKid 12 жыл бұрын
if you understand Advanced Javascript You Can Understand C++
@angeldominguez1
@angeldominguez1 12 жыл бұрын
we also dont need the system("pause"); anymore uh
@FrankLopezx
@FrankLopezx 9 жыл бұрын
WHAT TYPE OF ANSWER WILL I END UP WITH? will it say 2 3 4? i#include using namespace std; int main() { int B = 2; cout
@FrankLopezx
@FrankLopezx 9 жыл бұрын
any body can say that, but no one is going to give me the actual why breakdown
@FrankLopezx
@FrankLopezx 9 жыл бұрын
why 4,4? if i go with that notion i wud say 3-4
@FrankLopezx
@FrankLopezx 9 жыл бұрын
Jordan Filipovski those parameter can be change in cpp?
@FrankLopezx
@FrankLopezx 9 жыл бұрын
oh right yes i forgot my own example lol ur right
@johnflatt665
@johnflatt665 9 жыл бұрын
No sound on this or sololearn.
@nate9721
@nate9721 11 жыл бұрын
Except for variables maybe
@taylorsamy
@taylorsamy 12 жыл бұрын
at this rate by the end it will just be my you and @supersush269
@ShadowTetsuo9999
@ShadowTetsuo9999 11 жыл бұрын
seems you have a good summer break lol jkjk
@nate9721
@nate9721 11 жыл бұрын
I've heard that programming has to do a lot with math I still haven't seen the math side of it
@ajwayman4530
@ajwayman4530 6 жыл бұрын
twenty one... uh... twenty one
@SamGulz
@SamGulz 11 жыл бұрын
4 more in an year's time :P
@CoreyJayB
@CoreyJayB 12 жыл бұрын
craziness
@kems1592
@kems1592 5 жыл бұрын
Whats the use of this?
@joetomaselli8084
@joetomaselli8084 11 жыл бұрын
Are you trying to correct the amount of views? I mean, if so, then I don't think you understand how things change in time...
@Tulanir1
@Tulanir1 12 жыл бұрын
I never said 3D games :) i'm gonna start with 2D games
@rohankhanna8753
@rohankhanna8753 8 жыл бұрын
can we start java without c++ ?
@Tylernal
@Tylernal 8 жыл бұрын
Yes, C++ is more difficult and more useful than Java though.
@rohankhanna8753
@rohankhanna8753 8 жыл бұрын
i dont think so lol java is more useful than C++
@Tylernal
@Tylernal 8 жыл бұрын
Rohan Khanna It depends what you want to make. For game design, C++ is better.
@rohankhanna8753
@rohankhanna8753 8 жыл бұрын
and what java is good for can u plz tell me !!
@Tylernal
@Tylernal 8 жыл бұрын
Rohan Khanna Android apps
@tutorialvalley4890
@tutorialvalley4890 5 жыл бұрын
its really true that a school degree is useless :) thank go i am only 12 so i dont have to boder about that
@Tulanir1
@Tulanir1 12 жыл бұрын
Only 52 videos until i can start making games :D :/
@malteeaser101
@malteeaser101 9 жыл бұрын
'x = x + 10' is the same as 'x += 10'? Wow, now I can type one less character!
@brandonjohnson2491
@brandonjohnson2491 6 жыл бұрын
And you will be typing even less characters when the variable is longer than one character. Also, don't forget to count your spaces, they are typed characters as well.
@herp_derpingson
@herp_derpingson 12 жыл бұрын
Tell me more that you are the CEO of some international corporation.
@GBJaayy
@GBJaayy 3 жыл бұрын
Me watching this video in 2021 and that was the first ouput of the program (20 , 21 ) 😂😂
@gopinath27K
@gopinath27K 11 жыл бұрын
21st c++ video has 43144 views now
@nioway2198
@nioway2198 11 жыл бұрын
Hey guys does anyone think this is like way too easy?
@jeremyride1
@jeremyride1 8 жыл бұрын
anybody know a good free c++ builder program?
@deadspeakers
@deadspeakers 8 жыл бұрын
Visual Studio
@thavrisco1632
@thavrisco1632 7 жыл бұрын
I like code::blocks.
@poseidenjp1496
@poseidenjp1496 12 жыл бұрын
whats that ? :D
@alexandertouma5588
@alexandertouma5588 6 жыл бұрын
x=20; z; z=x++ + x++; what is the answer?
@Hairyson-g5j
@Hairyson-g5j 6 жыл бұрын
Alexander Touma: my answer is 41. So I guess for the first one you will get 20, and right after the first one x becomes 21, so for the second one you get 21, and z = 41, x= 22
@alexandertouma5588
@alexandertouma5588 6 жыл бұрын
@@Hairyson-g5j thank you, fellow Asian.
@ThePyrotechx
@ThePyrotechx 13 жыл бұрын
1 person has shaky hands.
@SuperTf2rocks
@SuperTf2rocks 9 жыл бұрын
V3rm
Buckys C++ Programming Tutorials - 22 - for Loops
4:59
thenewboston
Рет қаралды 432 М.
you will never ask about pointers again after watching this video
8:03
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 25 МЛН
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 70 МЛН
Sigma baby, you've conquered soap! 😲😮‍💨 LeoNata family #shorts
00:37
Issues with the pre- and postincrement operator in C, C++, etc.
5:32
Buckys C++ Programming Tutorials - 35 - Passing Arrays to Functions
7:59
My 2 Year Journey of Learning C, in 9 minutes
8:42
VoxelRifts (PixelRifts)
Рет қаралды 632 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 267 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 188 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 377 М.
Buckys C++ Programming Tutorials - 20 - Sentinel Controlled Program
9:41
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 25 МЛН