C++ FOR BEGINNERS (2020) - Nested if/else, Determine the type of a triangle PROGRAMMING TUTORIAL

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ต.ค. 2024

ความคิดเห็น • 83

  • @CodeBeauty
    @CodeBeauty  3 ปีที่แล้ว +15

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.

  • @phoebewell3653
    @phoebewell3653 4 ปีที่แล้ว +28

    This is great tutorial for all those who are starting to learn C++ or programming in general. Very usefull!

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว +6

      Thanks a lot. :)

  • @Cesar33-pl
    @Cesar33-pl 3 ปีที่แล้ว +7

    This is a very nice video. Just one more thing. We should first check if A+B>C && B+C>A && A+C>B so to have a valid triangle. (For example 2 3 7 is not a triangle). As for the method of teaching, it is excellent!

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +2

      Great contribution! 🥰

    • @atanusarkar8384
      @atanusarkar8384 2 ปีที่แล้ว

      Thank you mate for this insight. Attention to details.🙂

  • @0xzi
    @0xzi 3 ปีที่แล้ว +3

    After bouncing my head off a bunch of tutorials in the past and ultimately giving up I'm glad I found your channel! the ascii video and you challenging me to decipher it helped so much, but now moving on to these next few videos and having a visual laid out, it's just absolutely clicked with me. I feel like I'm on a roll, I even filled out the nested bit before you even explained how to do it!
    You are a fantastic teacher, I can't believe these are free. Most definitely subbed.

  • @killaburribo
    @killaburribo 3 ปีที่แล้ว +5

    You explain this in an easy and understandable manner! Very helpful, thank you. I just started my first semester in CS

  • @psk177
    @psk177 ปีที่แล้ว

    studying javascript but gave this a look since I've been struggling with nested if/else and the diagram really helped. Thanks

  • @anaglavina6721
    @anaglavina6721 8 หลายเดือนก่อน +1

    Pozdrav Saldina, za ovaj tutorijal (kao i za tvoj kanal istovremeno) sam saznala tako sto nam ga je preporucio profesor C++ sa Floride . Bravo devojko! 😊

    • @CodeBeauty
      @CodeBeauty  8 หลายเดือนก่อน +1

      Drago mi je da me i tamo gledate, nadam se da si našla korisnog materijala na mom kanalu. Veliki pozdrav! 🥰

  • @bmpersonal6403
    @bmpersonal6403 3 ปีที่แล้ว +1

    Thanks so much for all of these videos

  • @bappo231
    @bappo231 3 ปีที่แล้ว +3

    I cant say this is Great, this is not the Great, this is BEST.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +2

      I'm so happy that I can help 🤗🥰

  • @antonchernukha4043
    @antonchernukha4043 4 ปีที่แล้ว +1

    Very good example to learn if/else statement, thanks. We also can add the case when one of the lengths is equal to 0, then it is not a triangle.

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว

      Yes! Excellent idea, checking for 0 or a negative number is a great way to improve this code!

  • @koniecharity8217
    @koniecharity8217 2 ปีที่แล้ว

    You're a life saver

  • @greyhnd001
    @greyhnd001 3 ปีที่แล้ว +1

    Ok after all this work. I found you have to enter the lengths only separated by spaces.
    Seems like someone on here could have given me a heads up or something. Thanks for the troubleshooting experience.
    I keep gettting Scalene so I added a check at the end to see what a b c was. Fixed sort of.
    This was the output:
    a, b, c7,7,7
    Scalene Triangle
    7
    0
    4.59163e-41.
    So why is this happening? I was able to get it working only by getting the lengths 1 at a time.
    This the code I got to work:
    #include
    using namespace std;
    int main()
    {
    float a,b,c;
    //variables
    float aside, bside, cside;
    //enter side a
    cout

  • @elfrate
    @elfrate 3 ปีที่แล้ว +1

    Great video!
    I'm writing from Italy and here we're taught that equilateral triangles are a subclass of isosceles triangles. I'm surprised that you follow Euclid's thinking (isosceles triangles have two AND ONLY two sides of equal length): may I ask you if that was a choice to simplify the video or indeed you have that difference in mind?

  • @McconneIIRet
    @McconneIIRet 3 ปีที่แล้ว +3

    Pretty good, although as someone who is bad at math, part of me is pained to be dealing with geometry again.

  • @lickguitars1276
    @lickguitars1276 ปีที่แล้ว

    which one is better? else if or if nested under else ? luv to hear from you.

  • @subratadas9772
    @subratadas9772 2 ปีที่แล้ว +1

    THANKS FOR MAKING THIS VIDEO.

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว +1

      you're welcome ☺️😀

  • @cuol5675
    @cuol5675 3 ปีที่แล้ว

    i was following and not to complete to the end of the line and try to do it my self, it was very helpful and literally just after you wrote
    if (a == b && b == c)
    {
    cout

  • @ahyungrocks5509
    @ahyungrocks5509 3 ปีที่แล้ว

    Got me thinking hard on this one.

  • @Stoogette87
    @Stoogette87 3 ปีที่แล้ว +1

    Thank you so much for this series, I have just started a degree in software engineering, and have been struggling with my lecturer's teaching style, I was ready to give up. These tutorials have literally saved my faith in my ability as I actually understand you and your explanations. Thank you!!
    One thing, I believe I have copied this code exactly as it appears here, yet I keep getting "scalene" no matter what numbers I enter into the program. What do you think I could have missed that is causing this?

    • @vk2ig
      @vk2ig 3 ปีที่แล้ว +2

      Are you separating the numbers with spaces? For example, "2,2,2" will result in "scalene", whereas "2 2 2" will result in "equilateral".

    • @Stoogette87
      @Stoogette87 3 ปีที่แล้ว +2

      @@vk2ig Oh wow, I feel really silly now! That was it,, thank you so much!

    • @vk2ig
      @vk2ig 3 ปีที่แล้ว +3

      @@Stoogette87 No problems, and please don't feel silly - this is part of learning to code: try some stuff, and if it doesn't work then try something different. :D

    • @Stoogette87
      @Stoogette87 3 ปีที่แล้ว +2

      @@vk2ig True, true. I'll definitely remember to try different things now aha, thanks again!

  • @grayfoxtrots
    @grayfoxtrots 3 ปีที่แล้ว +1

    Thank you for sharing. So do many different programmers deal with “cleaning” as much when typing along each line?

  • @vvkbees6473
    @vvkbees6473 3 ปีที่แล้ว

    Спасибо , мне как начинающему очень полезно и наглядно. Thank you)

  • @haroldw2823
    @haroldw2823 4 ปีที่แล้ว +1

    Just curious, how many if/else statements should you use.
    Awesome stuff CodeBeauty, loving this stuff.

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว +2

      You can use as many as you need - your program is going to work. But, after some time (three or four if/else-s) it becomes kinda hard to read, and instead of adding more if-s and else-s better solution would be to use "switch/case" (if that is possible of course)
      If/else is often better for checking expressions that result as bool values, whereas switch/case is used if you have other data values (numbers, characters, etc.)
      In if/else statement, you are going to decide whether to execute if or else block, but in switch/case you decide which case you are going to execute.
      In this playlist, you can find an example of how to use switch/case and build a calculator app. That video would give you pretty good idea of how switch/case is used.

    • @haroldw2823
      @haroldw2823 4 ปีที่แล้ว +2

      @@CodeBeauty Thanks mate,
      Not many creators offer such in-depth explanations to questions asked, you are truly unique in this.
      Thanks for putting the fun back into learning :)

  • @danishriaz8267
    @danishriaz8267 24 วันที่ผ่านมา +1

    nice

  • @traianbadea7389
    @traianbadea7389 4 ปีที่แล้ว +1

    is very good your tutorial - all the best

  • @barryfinn2538
    @barryfinn2538 3 ปีที่แล้ว +1

    learning so much from you. it is giving me the confidence to experiment with programming. I hope you don't mind but I have changed your example just to see if I can actually get it to work.....what do you think of the result?
    #include
    using namespace std;
    int main()
    {
    repeatme: // allows program to reset from this point
    // user enters lengths of a triangle (a,b,c)
    // program should output whether the triangle is equilateral, isoscelese or scalene
    float a, b, c;
    cout > a;
    cout > b;
    cout > c;
    cout

  • @simveasna9529
    @simveasna9529 3 ปีที่แล้ว +1

    your lesson is very good and good explain can create more video about C++ create website

  • @pimpmetapod7906
    @pimpmetapod7906 3 ปีที่แล้ว +1

    This is amazing. Thank you 😊

  • @jerseychou4323
    @jerseychou4323 ปีที่แล้ว

    Thank you for your nice video.

  • @tawansiforlifetfl9987
    @tawansiforlifetfl9987 4 ปีที่แล้ว +1

    I think it would work also if we used the (if - else if - else) statement, wouldn't that be easier than a nested if-else statement?
    And thank you so much for the video, I believe your channel has saved my university future in Computer Science.
    Muchas gracias

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว +3

      Yes, this can be written as:
      if(a==b && b==c)
      ..equilateral
      else if (a!=b && a!=c && b!=c)
      ..scalene
      else
      ..isosceles
      I plan to publish tutorials for a long time, so there will be a lot of things to study on this channel. 🤓

    • @tawansiforlifetfl9987
      @tawansiforlifetfl9987 4 ปีที่แล้ว

      @@CodeBeauty Then I will graduate, thank you so much Mrs.Saldina. Much Respect For You. Have a great life.

    • @traianbadea7389
      @traianbadea7389 4 ปีที่แล้ว +1

      @@CodeBeauty Good news about your planing to publish tutorial for long time

  • @EyeNeo
    @EyeNeo 3 ปีที่แล้ว

    We can also use
    if ( a == b == c )

  • @ROYALNIL_SITE
    @ROYALNIL_SITE ปีที่แล้ว

    thanks saldina !

  • @devinitystudios433
    @devinitystudios433 3 ปีที่แล้ว

    If a==b
    if b==c
    equilateral
    else
    isosceles
    else
    if b==c
    isosceles
    else
    scalene

  • @nokokgomo__lazzy
    @nokokgomo__lazzy ปีที่แล้ว

    what if I declared my variables as of "double"' data type ? Would you mind explaining?

  • @waraxe09
    @waraxe09 3 ปีที่แล้ว

    veeerrryyy helpful thank you...

  • @anamggss
    @anamggss ปีที่แล้ว

    Great video! I have a question though, is there a way to connect the else to it's respective if? I'm currently finding myself using multiple nested statements (right now I have 2 if elses inside another one) and it's easy to connect the 1st and 3rd elses but the 2nd one seems to always get an "expected expression" error.
    PS I know this probably isn't the best way of doing this, Im just starting out.

  • @kunwarpalsingh8098
    @kunwarpalsingh8098 2 ปีที่แล้ว

    Is it possible to write another if else situation in the second if else situation?

  • @jaezybeats5862
    @jaezybeats5862 4 ปีที่แล้ว +1

    LOL im 16 and im trying to learn to code. Awesome vid CodeBeauty!
    One more thing, when I put the else it shows as an error and says that it expects a statement. I tried everything and i couldn't get it to execute. Do you think you might know why??

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว

      Hi 🤗 Paste your code here please 😊

    • @akshitamanpuria1864
      @akshitamanpuria1864 4 ปีที่แล้ว

      I had the same problem so I just deleted the word "else" and every code after it and the did it again so there was no problem

    • @RichOffClip
      @RichOffClip 3 ปีที่แล้ว

      Hey bro, i just started Coding. how's it been for you so far?

  • @ninadpatankar441
    @ninadpatankar441 ปีที่แล้ว

    Is it python a advanced version of c++? In python we have elif operations. Does this present at c++ also?

  • @mhdjaseem3195
    @mhdjaseem3195 3 ปีที่แล้ว

    thanks, mam💕💖

  • @philipsheard624
    @philipsheard624 3 ปีที่แล้ว +2

    // Can you help me please. when i start the program and enter a b or c all i get is isosceles.
    //what should i be inputting? Where could I be going wrong?
    Thank you x

    #include
    using namespace std;
    int main()
    {
    float a, b, c;
    cout > a >> b >> c;
    if (a == b && a == c)
    {
    cout

  • @hassanabdelaziz3505
    @hassanabdelaziz3505 2 ปีที่แล้ว

    How to set a condition for a Pythagoras triangle

  • @khaleddak
    @khaleddak 3 ปีที่แล้ว

    please tell me why we didn't write in the second condition like the first one to be (a!==b&&a!==c&&b!==c) .thank you

  • @40wattstudio41
    @40wattstudio41 ปีที่แล้ว +1

    Interesting, it works without any brackets for the if/else statements.
    if (a == b && b == c)
    cout

    • @CodeBeauty
      @CodeBeauty  ปีที่แล้ว +1

      It works without brackets if you have only one command, but if you have a block of commands then curly brackets are necessary 🙌

    • @40wattstudio41
      @40wattstudio41 ปีที่แล้ว

      @@CodeBeauty Good to know, thanks!

  • @mareklewanski2198
    @mareklewanski2198 3 ปีที่แล้ว

    The idea of expenation is perfect but it doesnt work in real math ;-)

  • @rifat.ahammed
    @rifat.ahammed 2 หลายเดือนก่อน

    This is an equilateral Triangle

  • @laxus7764
    @laxus7764 3 ปีที่แล้ว

    ma'am you said that if we have one command inside an if else statement then we can delete the curly brackets but from line 16 to 21 we don't have only one command so how can we delete the brackets?

    • @philipyip1988
      @philipyip1988 3 ปีที่แล้ว

      When 16 and 21 are deleted the middle else and if are combined into an else if statement which only has one command. This gives a cascading structure opposed to a nested structure with multiple indentation levels. The video would have been a wee bit better if this was explained towards the end but otherwise is a solid explanation.
      Nested:
      if(con1){code for con1}
      else{
      if(con2){code for con2}
      else{code for no con}
      }
      Cascading:
      if(con1){code for con1}
      else if(con2){code for con2}
      else{code for no con}

  • @antoninostracuzzi1321
    @antoninostracuzzi1321 3 ปีที่แล้ว

    weel in this case I prefer python, because have if, elif....... and finally else

  • @benmcwhirter4566
    @benmcwhirter4566 2 ปีที่แล้ว

    Of I input d then it says equilateral triangle. Who new.

  • @othmanalghandour7301
    @othmanalghandour7301 2 ปีที่แล้ว

    #include
    using namespace std;
    // User enter length of triangle (a, b, c)
    // then lets decide the nature of the triangle whatever its isosceles, equilateral , scalene
    int main()
    {
    int s1, s2, s3;
    cout s1 >> s2 >> s3;
    if (s1 == s2 && s1 == s3)
    {
    cout

  • @joekh4736
    @joekh4736 3 ปีที่แล้ว +1

    Merry me :3

  • @imnot9923
    @imnot9923 2 ปีที่แล้ว

    Comment for Algor

  • @robertosxo
    @robertosxo 4 ปีที่แล้ว

    I started testing if and else, and if the user types letters, how to make the program ask for numbers to be typed.
    I tried to do it, but stuck in that part.
    I copied the code in the paste bin::: pastebin.com/s0N4KL42
    a tip for the next videos is to propose two or three exercises to be corrected at the beginning of the next video or in a separate video.

    • @robertosxo
      @robertosxo 4 ปีที่แล้ว

      #include

      using namespace std;
      /*
      if the user types numbers, the program keeps checking what type of triangle it is.
      If the user enters a letter, the program will ask for numbers to be entered.
      */
      int main()
      {

      float n1, n2, n3, checker;

      cout > n1 >> n2 >> n3;
      if (n1 && n2 && n3 == checker) //my problem is here.
      {
      if (n1 == n2 && n2 == n3)
      {
      cout