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

Поделиться
HTML-код
  • Опубликовано: 23 ноя 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.

  • @Cesar33-pl
    @Cesar33-pl 4 года назад +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.🙂

  • @phoebewell3653
    @phoebewell3653 4 года назад +28

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

  • @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

  • @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.

  • @psk177
    @psk177 2 года назад

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

  • @anaglavina6721
    @anaglavina6721 9 месяцев назад +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  9 месяцев назад +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

  • @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.

  • @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!

  • @bappo231
    @bappo231 4 года назад +3

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

    • @CodeBeauty
      @CodeBeauty  4 года назад +2

      I'm so happy that I can help 🤗🥰

  • @koniecharity8217
    @koniecharity8217 2 года назад

    You're a life saver

  • @vvkbees6473
    @vvkbees6473 3 года назад

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

  • @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

  • @devinitystudios433
    @devinitystudios433 3 года назад

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

  • @subratadas9772
    @subratadas9772 2 года назад +1

    THANKS FOR MAKING THIS VIDEO.

    • @CodeBeauty
      @CodeBeauty  2 года назад +1

      you're welcome ☺️😀

  • @ahyungrocks5509
    @ahyungrocks5509 3 года назад

    Got me thinking hard on this one.

  • @lickguitars1276
    @lickguitars1276 Год назад

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

  • @grayfoxtrots
    @grayfoxtrots 3 года назад +1

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

  • @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

  • @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?

  • @traianbadea7389
    @traianbadea7389 4 года назад +1

    is very good your tutorial - all the best

  • @EyeNeo
    @EyeNeo 3 года назад

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

  • @pimpmetapod7906
    @pimpmetapod7906 3 года назад +1

    This is amazing. Thank you 😊

  • @jerseychou4323
    @jerseychou4323 Год назад

    Thank you for your nice video.

  • @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 :)

  • @simveasna9529
    @simveasna9529 3 года назад +1

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

  • @Stoogette87
    @Stoogette87 4 года назад +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!

  • @anamggss
    @anamggss 2 года назад

    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.

  • @nokokgomo__lazzy
    @nokokgomo__lazzy Год назад

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

  • @danishriaz8267
    @danishriaz8267 Месяц назад +1

    nice

  • @ninadpatankar441
    @ninadpatankar441 Год назад

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

  • @waraxe09
    @waraxe09 3 года назад

    veeerrryyy helpful thank you...

  • @RennaisanceSoul
    @RennaisanceSoul 3 года назад

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

  • @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

  • @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

  • @ROYALNIL_SITE
    @ROYALNIL_SITE Год назад

    thanks saldina !

  • @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

  • @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

  • @mhdjaseem3195
    @mhdjaseem3195 3 года назад

    thanks, mam💕💖

  • @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?

  • @hassanabdelaziz3505
    @hassanabdelaziz3505 2 года назад

    How to set a condition for a Pythagoras triangle

  • @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!

  • @laxus7764
    @laxus7764 4 года назад

    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}

  • @rifat.ahammed
    @rifat.ahammed 3 месяца назад

    This is an equilateral Triangle

  • @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

  • @antoninostracuzzi1321
    @antoninostracuzzi1321 3 года назад

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

  • @mareklewanski2198
    @mareklewanski2198 3 года назад

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

  • @benmcwhirter4566
    @benmcwhirter4566 2 года назад

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

  • @joekh4736
    @joekh4736 3 года назад +1

    Merry me :3

  • @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

  • @imnot9923
    @imnot9923 2 года назад

    Comment for Algor