Buckys C++ Programming Tutorials - 17 - if / else Statement

  Рет қаралды 589,744

thenewboston

thenewboston

Күн бұрын

Пікірлер: 326
@oldcowbb
@oldcowbb 5 жыл бұрын
age=3 bucky: get a job
@Yes-ev3sr
@Yes-ev3sr 4 жыл бұрын
Lol
@Braleven
@Braleven 10 жыл бұрын
See, this is the easier stuff. Those last few tutorials on classes got me really tangled once you introduced constructors.
@beri4138
@beri4138 7 жыл бұрын
A constructor in a class is the same as a function in a class. The only differences are: - A constructor has the same name as the class itself. - Instead of being called, a constructor runs automatically when you declare an object of that class.
@top10detrax45
@top10detrax45 7 жыл бұрын
cool you just cleared out my doubts :D
@nepalihercules
@nepalihercules 6 жыл бұрын
when in doubt, cout.
@dbc201theking
@dbc201theking 6 жыл бұрын
Gaming Turkey Also constructors don’t return anything?
@theseangle
@theseangle 4 жыл бұрын
@@dbc201theking they physically can't
@RunItsTheCat
@RunItsTheCat 10 жыл бұрын
I am 500 years old and I am offended.
@DerickZ28
@DerickZ28 10 жыл бұрын
Why are you still alive?
@Pinkiepyro1
@Pinkiepyro1 10 жыл бұрын
stonecoldtrk probably cheats.
@ТайныйЯ-к3ь
@ТайныйЯ-к3ь 9 жыл бұрын
Constantine Leon Don't be so rude...
@Pinkiepyro1
@Pinkiepyro1 9 жыл бұрын
Тайный Я It was in reference to the video.
@ТайныйЯ-к3ь
@ТайныйЯ-к3ь 9 жыл бұрын
Pinkiepyro1 I know.:D
@meganradley7084
@meganradley7084 9 жыл бұрын
This is perfect! I love the way you describe these so easily, it really makes sense. Thank you so much for these!
@BradenBest
@BradenBest 8 жыл бұрын
Would've been a perfect opportunity to introduce the && operator. Also, just because you can nest if blocks, doesn't mean you should. Unnecessary nesting leads to unnecessary complexity. Use functions instead. if(someCondition) functionForThatCase([necessary values]); else someOtherFunction([etc])
@KlaPzCA
@KlaPzCA 6 жыл бұрын
I just made something really simple with if/else statement I'm happy to see myself progressing... #include using namespace std; int main() { int x; cout x; if(x
@dibbiepk
@dibbiepk 12 жыл бұрын
"Wow, you are old" "You are young, geta job" What a nice and friendly program, HOW MUCH!? :P
@shemecnebissamyaro
@shemecnebissamyaro 8 жыл бұрын
I'm 178 years old and I find this offensive.
@xXLanyuzAnlunXx
@xXLanyuzAnlunXx 8 жыл бұрын
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
@MOHAMDMEZAR1
@MOHAMDMEZAR1 8 жыл бұрын
+Nik Losi looooooooooooool
@asp3766
@asp3766 8 жыл бұрын
oooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
@pongangelo2048
@pongangelo2048 8 жыл бұрын
"178 years old? That's cute..." - Gandalf
@TheToonyToonShow1
@TheToonyToonShow1 8 жыл бұрын
+IWasSherpaHigh I love you
@raptor_2277
@raptor_2277 10 жыл бұрын
Someone is going to watch this in 2500 and be greatly offended by you saying "if you are 178 years old, you should be dead."
@marcopolo5541
@marcopolo5541 5 жыл бұрын
Do you think C++ will still be relevant by then? Or worse, do you think humans will still be relevant by then?
@dashcampower4622
@dashcampower4622 4 жыл бұрын
@@marcopolo5541 c++ has like infinite potential. its an extension to C and its library gets bigger and bigger like every 2 years
@nipunfernando7688
@nipunfernando7688 7 жыл бұрын
Wow this helped alot, I was confused with these at first but not anymore. Thanks bro
@ionyjula2488
@ionyjula2488 12 жыл бұрын
wow Bucky...you are the best teacher online. 10 of 10!!!! I did"n know nothing about programming and now...I am learning C++...with the best teacher in the world. Yours videos are AWESOME!!!!!God bless you! and many thanks!!!
@odo432
@odo432 11 жыл бұрын
I am doing exactly this. Helps allow me to remember stuff from previous tutorials while integrating them in the newer ones. Usually I forget everything I learn soon after so now I have created a personalised forum. Writing everything down with my own examples and at the end make example programs which integrate everything I have learned.
@TheYousif5
@TheYousif5 12 жыл бұрын
create an int call it "age", put "cin
@justinzheng3000
@justinzheng3000 2 жыл бұрын
C++ is kinda insane
@Qazqi
@Qazqi 11 жыл бұрын
You can do if (std::getline(...)) to check whether it succeeded or if (std::getline(..., line) && line == "wanted line") to check if it succeeded and is the proper line.
@Blank-fe6wi
@Blank-fe6wi 2 жыл бұрын
Most of the times it's those technical terms that confuse and scare the sh*t out of you. Thanks for making such a each to understand tutorial.
@church778
@church778 12 жыл бұрын
Yes, it will. The program works top to bottom, so if there is a line before the nested if statement, it will run it since the first if statement was true.
@dizzykitten9243
@dizzykitten9243 9 жыл бұрын
awesome, I dont know if he went over this because I stopped and wanted to try a few codes and with the prior knowledge I made them enter their age and if it was younger than 15yrs old it would say "Hey there young son" if it was older it would say "hey there elderly" PROUD OF MYSELF :D IM LOVING C++
@dustbinsavesyou8283
@dustbinsavesyou8283 6 жыл бұрын
lol, I had python knowledge from the start so I wrote that in just 1hr learning c++
@nemesi8800
@nemesi8800 6 жыл бұрын
Yeah same :D Knowing any programming language, even with easy syntax like Python helps a lot. Otherwise I'd be struggling and be like... "wut.. why do I need this?" "What is this????" HEEEEEELP? lol
@newkid9807
@newkid9807 6 жыл бұрын
Nemesi rip
@gm3avxdd
@gm3avxdd 7 жыл бұрын
Technically there is a maximum nesting depth of 256 (including the function).
@Faraz9023
@Faraz9023 12 жыл бұрын
Wrong, first of all, its cin >> age, and not cin
@dayeemouwon
@dayeemouwon 10 жыл бұрын
I need help on my c++ program and the question is has follow: A box of cookies can hold 24 cookies, and a container can hold 75 boxes of cookies. Write a program that prompts the user to enter the total number of cookies, the number of cookies in the box, and the number of cookie boxes in a container. The program then outputs the number of containers to ship the cookies. Note that each box must contain the specified number of cookies, and each container must contain the specified number of boxes. if the last box of cookies contains less than the number of specified cookies, you can discard it and output the number of leftover cookies. similarly, if the last container contains less than the number of specified boxes, you can discard it and output the number of leftover boxes..
@ThatGuyNamedBender
@ThatGuyNamedBender 11 жыл бұрын
Not trying to brag but knowing some languages before learning C++ this was fairly simple for me ^^ For the people who are like me here is a good challange. Make a class that handles the age calculations. So that your main.cpp file would basically look like this. int main(){ { ourClass.requestAge(); return 0; } or something like that xD
@PuckishAngeI
@PuckishAngeI 3 жыл бұрын
me: *fucks up the code* age 3: "Why are you still alive?"
@MrAssassin1492
@MrAssassin1492 11 жыл бұрын
first video i have ever seen without dislikes.
@farristurner6443
@farristurner6443 4 жыл бұрын
Thank you! I'm learning from a 2003 textbook and it did not have the brackets...that's what was causing my code not to work
@coreydoyle4702
@coreydoyle4702 11 жыл бұрын
Theoretically, you can have an infinite number of if's inside of if's. -Cheers
@yoferenuntar6481
@yoferenuntar6481 9 жыл бұрын
do we have elif in the c++??? or we can just type if below the if???
@ai.201
@ai.201 5 жыл бұрын
Learn more from this then 1:20 hour slot at my stupid university.
@abhishekjaiswal3121
@abhishekjaiswal3121 7 жыл бұрын
thanx, buckys u give lot information about c++ , but i don't understand what constructor is ?
@Robber7
@Robber7 12 жыл бұрын
The marked text in the tumbnail for this video looks like a sniper rifle!
@MontSteve36
@MontSteve36 10 жыл бұрын
Thanks Bucky, I am 78!!!
@StoneSlayer
@StoneSlayer 11 жыл бұрын
Wow this is the first video with 100% like rate that i have seen!! Keep it up Bucky!!
@P3nk0
@P3nk0 13 жыл бұрын
umm what kind of compiler are u using bucky ps i love your videos keep them coming ;];]
@bilalarain4632
@bilalarain4632 8 жыл бұрын
I Love It
@sammy5576
@sammy5576 4 жыл бұрын
love your channel thanks you awsome teacher
@johnlarios87
@johnlarios87 3 жыл бұрын
hey man my earth is older than 187 years old
@TheCosmicChicken
@TheCosmicChicken 12 жыл бұрын
As soon as Bucky suggested testing if they're over 100, I was like "I would output 'How are you still alive?'". Then Bucky's like "And then we're gonna write...cout...um...why are you still alive?" And I was like ":O"!
@kaleab15
@kaleab15 10 ай бұрын
Re-record over that, otherwise great content. Thanks
@TheCosmicChicken
@TheCosmicChicken 10 ай бұрын
People do live to be over 100 sometimes. Perhaps a better output would be: "Congratulations on such a long life!"
@veer4419
@veer4419 5 жыл бұрын
"If you are over 100, why are you still alive?" - That is cold. I hope you know that now scientists are saying that people will easily live to 150, 200 years old in the not-so-distant future.
@simon-yi6jv
@simon-yi6jv 3 жыл бұрын
2:30 { cout
@frangallagher8941
@frangallagher8941 11 жыл бұрын
That is actually a brilliant idea! Nice thinking
@TehOnlyShoe
@TehOnlyShoe 11 жыл бұрын
Lots of different languages use the "if" statement. It's a common thing. But apart from that, yeah they are pretty dang similar lol.
@dylangriffiths7464
@dylangriffiths7464 11 жыл бұрын
Can you use the getline function with an if statement to verify if the users input is correct or not?
@allankamoga5477
@allankamoga5477 6 жыл бұрын
well understood..... the simplest tutorial
@Civik_123_
@Civik_123_ 2 жыл бұрын
Bro I'm 10 and I understand. You teach so good! Thank you
@mr.ANIMAT0N
@mr.ANIMAT0N 2 жыл бұрын
I am 106 and you have destroyed my dreams in learning programming. Just kidding 😛
@Halvard1992
@Halvard1992 10 жыл бұрын
I happen to be 178 and I find this offensive! >:3
@marianadeltoro8259
@marianadeltoro8259 10 жыл бұрын
hey newboston! how are? thank for your video. I am a college student and actually I'm in a class of C++ programing.. so, I have to make this lab assigment which is killing meeee. Is about turning arabic numbers to roman numbers... so I was thinking if I can use the if else stamente for make the program... cause the professor want that the program accept numbers of years of 4 digits... =/
@Smiling_Tears
@Smiling_Tears 11 жыл бұрын
Ok, I have a weird question. If I have a general loop and placed an if...else inside that loop, would that if statement be considered nested, or is an if statement only considered nested when it is within the scope of an outer if condition?
@yimjabo1
@yimjabo1 10 жыл бұрын
I don't know why but, for some reason, even though I have the same exact thing typed up as him I keep getting "warning: statement has no effect [-Wunused-value]". Can anyone help with that?
@rohanpandey9957
@rohanpandey9957 4 жыл бұрын
i have a question how to apply all these knowldege and i mean by that is how can we solve problem related to what he teaches us as if we dont do problems at that instant it will become of no use in future so pls guide me through it.
@StickMan1316
@StickMan1316 8 жыл бұрын
Here is what I came up with on my own after your if and else statement #include using namespace std; int main () { int x,y,z; cout > x; cout > y; cout
@MrPikmin3
@MrPikmin3 8 жыл бұрын
+StickMan1316 i came up with this after watching this video #include using namespace std; int main() { start: int add = 1; int subtract = 2; int multiply = 3; int divide = 4; int a; int b; int answer1; int sum; cout > answer1; if(answer1==add){ goto addition; } if(answer1==2){ goto subtraction; } if(answer1==3) { goto multiplication; } if(answer1==4) { goto division; } if(answer1 > 4) { goto error; } if(answer1 < 1) { goto error; } addition: cout > a; cout > b; sum = a + b; cout
@StickMan1316
@StickMan1316 8 жыл бұрын
+Lukas Pratt Thats good. later in the c++ tutorials ur gonna learn about the switch statement... you are going to love!!!!!
@MrPikmin3
@MrPikmin3 8 жыл бұрын
sure will, thanks
@givup_
@givup_ 11 жыл бұрын
i know that this is pretty late but it doesn't print the else statement becouse there is no else statement for that if statement. That else statement is for the if(age > 100). Sorry for the bad english and hope i helped even a little.
@Himanshukumar-ow3fx
@Himanshukumar-ow3fx 5 жыл бұрын
bro i want answer of 1 question blowing my mind i spend 2 days on this still not done soccer club registring boys and girls for their camp,club represent player with there group as follow age =4 to 7. micro group 8 to 11 . junior group 12 to 15 . juvenile group 16 to 18 . senior group program to calculate 1.show in which category player will be. 2.how many players in each category. can you help me out bro
@crimsonking3873
@crimsonking3873 6 жыл бұрын
can someone tell me why it says the the else If will never be executed //OPTIONS if (options == "Ranged" || "ranged") {cout > ranged;} else if (options == "Melee" || "melee") {cout
@crimsonking3873
@crimsonking3873 6 жыл бұрын
Oh......
@crimsonking3873
@crimsonking3873 6 жыл бұрын
Actually I was going to look up what you said since Im still new to programming and have memory loss so I have to take a lot of notes. Thanks for saving me time telling me.
@RuberSocks
@RuberSocks 12 жыл бұрын
now your getting it
@ninjasensei9834
@ninjasensei9834 9 жыл бұрын
2:45, turn on captions, LYAO.
@stick4508
@stick4508 4 жыл бұрын
Lmao.
@brandlax
@brandlax 12 жыл бұрын
Bucky should give us 'homeworks' so that we can practice it better! :D
@jeppemolin42069
@jeppemolin42069 6 жыл бұрын
how would i use the if statement but for currency i want to attempt to use it as an if Kr is more zero or less euro is x times that ?
@jasimali9031
@jasimali9031 3 жыл бұрын
Can you please give ma a link of 18th lecture?
@Benzzzy.
@Benzzzy. 4 жыл бұрын
I really love his voice
@TheaDragonSpirit
@TheaDragonSpirit 12 жыл бұрын
I prefer 'if', then 'else if'... and 'else' as a safety net encase something went wrong and you really don't know why or what could have happened. For example, I type a letter and not a number. :P
@josephscinto9358
@josephscinto9358 3 жыл бұрын
I love your sarcasm
@Sufi39
@Sufi39 3 жыл бұрын
10 year anniversary?
@playertwo4558
@playertwo4558 2 жыл бұрын
My esle statement looks exatcly the same, but no matter what I try it gives me only the if statements answer
@NikorasuChan
@NikorasuChan 8 жыл бұрын
TRIGGERED!!!!!!
@theminecraftsorcerer3061
@theminecraftsorcerer3061 8 жыл бұрын
the only thing i hate about learning from videos is that i can't directly ask you why my program isn't working and show you my screen.
@newkid9807
@newkid9807 6 жыл бұрын
The Minecraft Sorcerer ok minecraft sorcerer
@RAFMnBgaming
@RAFMnBgaming 8 жыл бұрын
somewhere yoda is looking at this and thinking "bitch please".
@dmitrij34
@dmitrij34 12 жыл бұрын
Awesome Bucky!
@mrsmileycorps
@mrsmileycorps 11 жыл бұрын
what i am doing is making a text based game and slowly improving it with the concepts i learn from bucky. Although im pretty sure you already know c++ by now XD
@honeypot11
@honeypot11 13 жыл бұрын
"let me go even deeper" Thats what he said lol.
@Parkseo226
@Parkseo226 7 жыл бұрын
hey why we are not using cin here? when we exactly use cin?
@TheaDragonSpirit
@TheaDragonSpirit 12 жыл бұрын
Has anyone else noticed that a small case "L" looks just like "1" or a One in this program. Sometimes I copy what he has put and my brain instinctively goes to the 1 key and not L. How odd.
@SinisterShrink
@SinisterShrink 11 жыл бұрын
Well he did say, "Let's go DEEPER...." So I think he was subliminally referencing to Inception. Nobody will ever know.....
@Xaeroxe
@Xaeroxe 11 жыл бұрын
You must be new to this :P A basic windows program has a WndProc that runs a switch statement that runs several layers of if statements, and is connected to functions outside of the WndProc. Shit gets complicated real fast :P
@TakingItCasual
@TakingItCasual 13 жыл бұрын
Awesome!
@SinisterShrink
@SinisterShrink 11 жыл бұрын
Question: Would nesting an if inside of an else be the same as an "else if" in Java coding?
@1...........123-t9b
@1...........123-t9b 4 жыл бұрын
No
@pedro_navarro
@pedro_navarro 10 жыл бұрын
I hope our next generations don't ask some people the same question.
@zombieat
@zombieat 8 жыл бұрын
do you really need the extra curly brackets before and after else?
@siaogaboh
@siaogaboh 8 жыл бұрын
+mohammed6649 not necessarily, but a good practice, for readability of code.
@limyonghun081297
@limyonghun081297 8 жыл бұрын
i have a qns, if i put if else statement under if else statement is it possible? e.g if ( year ==1 ) { if (category == 1) { printf("ur great") } else if(category == 2) { printf("ur cool") } } else if ....... need help ASAP thanks
@Tylernal
@Tylernal 8 жыл бұрын
;
@chronixthegod
@chronixthegod 8 жыл бұрын
This is C, not C++...
@KeyurKumbhare
@KeyurKumbhare 7 жыл бұрын
keyurk42.blogspot.in Find the notes of Bucky's C++ programming tutorials over here. Do share the message so that everyone can get the benefit.
@ArdawanKurdi
@ArdawanKurdi 3 жыл бұрын
Thank u dude
@shehuadesanya1990
@shehuadesanya1990 10 жыл бұрын
You should be arranging your work well Great work btw
@DulajMiuranga
@DulajMiuranga 10 жыл бұрын
Thankzzzzz a lot
@xs732
@xs732 7 жыл бұрын
You're hilarious Bucky and you sound like JMSN
@dibbiepk
@dibbiepk 12 жыл бұрын
IF AND ELSE! WHOO! (I already know all about this, still) I wonder what the next one is =D
@Bigdamndawg
@Bigdamndawg 3 жыл бұрын
U r a BEAST
@TheSplendidSpiders
@TheSplendidSpiders 12 жыл бұрын
I wish I could get a raise from an if statement.
@adkadatka244
@adkadatka244 9 жыл бұрын
#include using namespace std; int main() { string a; int b; cout > a; cout > b; if (b
@Brainimplodes
@Brainimplodes 9 жыл бұрын
Nice but could use some tidying up like aligning both "cout"s in the if/else statement for easier readability. Also like in Bucky's video, I'm personally like the look of my first curly bracket being in the same line as my "if/else" instead of going to a new line.
@xXLanyuzAnlunXx
@xXLanyuzAnlunXx 8 жыл бұрын
+adka datka use void int main { }
@xXLanyuzAnlunXx
@xXLanyuzAnlunXx 8 жыл бұрын
ikr :D
@adkadatka244
@adkadatka244 8 жыл бұрын
***** I wrote it on code::blocks #getRekt
@habbo159
@habbo159 7 жыл бұрын
lmao
@engrxtianbautista
@engrxtianbautista 7 жыл бұрын
You're 30 years old by now.
@bakat2454
@bakat2454 5 жыл бұрын
29 people disliked because they’re over 178 years old and they’re offended
@Subakak
@Subakak 6 жыл бұрын
You could type in a cin command
@REALCOOLLIKEVIPUL
@REALCOOLLIKEVIPUL 12 жыл бұрын
Why KZbin gives me error when i try to paste code? How do you guys do it?
@meganathansubramani2070
@meganathansubramani2070 11 жыл бұрын
Is there any way to print one cout statement 10 times?
@shadidhaque7518
@shadidhaque7518 11 жыл бұрын
i was trying to combine switch and if together but getting errors...help.plz..
@archavez100
@archavez100 11 жыл бұрын
KZbin won't let me post it. I'll PM you.
@krishsabori6803
@krishsabori6803 7 жыл бұрын
How we can make if else statements to show vowel and consonant letters
@krishsabori6803
@krishsabori6803 7 жыл бұрын
How can solve my problem please send me my answer
@saravanan335
@saravanan335 Жыл бұрын
Clear👌👌
@Khalinakhe
@Khalinakhe 12 жыл бұрын
I am 178 years old and I find this offensiveve!
@thefridge9278
@thefridge9278 6 жыл бұрын
why is this in a bad meets evil playlist??
@WeedManShow
@WeedManShow 8 жыл бұрын
Nice!
@animfix2840
@animfix2840 6 жыл бұрын
Buckys spelling> my spelling
@hutlazzz
@hutlazzz 5 жыл бұрын
thanks
Buckys C++ Programming Tutorials - 18 - while Loops
6:10
thenewboston
Рет қаралды 641 М.
why are switch statements so HECKIN fast?
11:03
Low Level
Рет қаралды 420 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 25 МЛН
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 110 МЛН
兔子姐姐最终逃走了吗?#小丑#兔子警官#家庭
00:58
小蚂蚁和小宇宙
Рет қаралды 10 МЛН
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН
C++ if statements (#6) ❓
14:05
Bro Code
Рет қаралды 7 М.
Buckys C++ Programming Tutorials - 27 - Random Number Generator
9:53
He Did It!!! - 16th Player Ever to Break the 2800 Barrier!
14:19
agadmator's Chess Channel
Рет қаралды 8 М.
Learn C++ With Me #8 - If, Else & Else If
17:05
Tech With Tim
Рет қаралды 36 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 917 М.
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 767 М.
Buckys C++ Programming Tutorials - 20 - Sentinel Controlled Program
9:41
Conditions - C++ Tutorial For Beginners #9
7:47
NeuralNine
Рет қаралды 10 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 25 МЛН