ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

C++ Ternary Operator (Conditional Operator) | CPP Video Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ส.ค. 2024
  • In this c++ / cpp programming video tutorials / lecture for beginners video series, you will learn about the ternary operators with example.
    You will lean what are the ternary operators and also how to use them in your program, how a ternary operator can be used as alternative to simple if and else in detail with examples.
    Visit www.LearningLad.com to get the SOURCE CODE of this tutorial and to watch more free computer programming video tutorials.
    Learn Programming in HINDI at our youtube channel
    / learningladhindi
    Catch us on Social Media
    / learninglad
    www.google.com/+LearningLad
    / learningladedu

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

  • @IrfanAli-mg9gf
    @IrfanAli-mg9gf 8 ปีที่แล้ว +25

    I have gained more knowledge by watching your videos than referring books written by top Authors..!!Awesome Tutorials and keep doing the good WORK.!!

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว +5

      +Irfan Ali
      happy to hear that.
      Thank you :)

  • @ok-dt8db
    @ok-dt8db 8 ปีที่แล้ว +12

    i did it #include
    using namespace std;
    int main()
    {
    int mark;
    cout > mark;
    mark >=35 ? cout

  • @robertfaubion1311
    @robertfaubion1311 6 ปีที่แล้ว +7

    I really appreciate your lessons. You are excellent in teaching. Thanks for all the effort.

    • @LearningLad
      @LearningLad  6 ปีที่แล้ว

      my pleasure.
      keep learning :)

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

    Watching this in 2020 and still it is the best tutorials that you can find online.

  • @shankarirajd8645
    @shankarirajd8645 5 ปีที่แล้ว +4

    I watched all the videos in c++.... learned a lot...even have more clarity than before.... thanks a lot... good work.. God bless you

    • @LearningLad
      @LearningLad  5 ปีที่แล้ว

      thank you.
      keep learning :)

  • @aliyakubu6449
    @aliyakubu6449 5 ปีที่แล้ว +4

    Great delivery.The first time I understood this concept of ternary very well.Keep the it up..

    • @LearningLad
      @LearningLad  5 ปีที่แล้ว

      awesome.
      keep learning :)

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

    thank you ma dude. you finally helped me to figure out my homework.

  • @devenwarang3687
    @devenwarang3687 7 ปีที่แล้ว

    awesome....very helful plzz keep uploading such videos

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

    holy shit, im glad i found these tutorials. I hope to soon be a c++ master with your tutorials. thanks man!! did you go to school for this?

  • @funny_adarsh_gamer
    @funny_adarsh_gamer 3 หลายเดือนก่อน

    It Is too good for understanding ❤❤❤❤❤

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

    omg thanks m8 cheers!
    1 question in my mind answered by watching this

  • @robertfaubion1311
    @robertfaubion1311 6 ปีที่แล้ว +7

    Will you ever do an OpenGL tutorial series? The internet needs your teaching style for such an advanced topic!! :)

  • @cororolyune4127
    @cororolyune4127 8 ปีที่แล้ว +2

    I love this dude! Keep up the good work!

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว

      +Cororo Lyune
      thank you :)

  • @ibrarsaqib598
    @ibrarsaqib598 8 ปีที่แล้ว

    I understand better by watching your posted video than study book
    Therefore,i am very grateful to you.........

  • @SpreakYT
    @SpreakYT 11 หลายเดือนก่อน +1

    Thanks for it 😊

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

    really awesome

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

    thanks man

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

    Hi when to use ternary over separate function? For example i have 3 different condition check in a function, can i use 3 ternary or 3 sub functions?

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

    THanks you so mcuh

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

    thanks a lot anil thats a wonderful explaination

  • @alitehrani2014
    @alitehrani2014 8 ปีที่แล้ว

    hi
    if i use for loops for getting several numbers,how can i use question mark?

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

    What if we have more than two conditions? like If, else if and else? could you please explain?
    Reply 2

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

    Only good for const veriables that need only two statements, you should still refer to (if else) conditions for clarity, readability and testing.

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

    Good video

  • @shivamsharma-wu4ru
    @shivamsharma-wu4ru 6 ปีที่แล้ว

    hey sir,, plzz explain if there is multiple ternary operator used in a program in the same line

  • @shivammenon2026
    @shivammenon2026 7 ปีที่แล้ว

    Nyc class

  • @youssefel-shabasy833
    @youssefel-shabasy833 6 ปีที่แล้ว +1

    ty

  • @alimam.7399
    @alimam.7399 ปีที่แล้ว +1

    thank u a lot
    i got it from the first watch

  • @SubSai
    @SubSai 7 ปีที่แล้ว

    Is it possible to nest the ternary operator ( Like nested ifs)??
    If so can you please tell how to do it??

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

    Extraordinary work brother

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

    you are the best !!!!

  • @CindyK9
    @CindyK9 9 ปีที่แล้ว

    When would you recommend (or not) programmers to use ternary operators instead of the basic else-if statements?

    • @IrfanAli-mg9gf
      @IrfanAli-mg9gf 8 ปีที่แล้ว +1

      +Cindy Yap The ternary operator does the work of a basic if-else in a single line making the code less complicated to understand.

  • @abhisekde7852
    @abhisekde7852 8 ปีที่แล้ว

    my output screen is not holding in codeblocks..please tell me how to hold it??

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

    Thanks alot

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

    Thx u so much

  • @steptowardsdestination2319
    @steptowardsdestination2319 7 ปีที่แล้ว +2

    you r doing a good job...
    i m too much week at prgrmng.. getting infrmations from u..
    but here is a prblm i cant see the prgrame clearly...

    • @LearningLad
      @LearningLad  7 ปีที่แล้ว

      thank you and i'm really glad that my tutorials are helping you.
      try to watch the video's in 1080p.
      we have solved this problem in our latest video's but the issue still exists in some of our old video's and i'm really sorry about that.
      Keep Learning :)

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

    Thank you sir

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

    thanku so much sir!!

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

    Thank you so much

  • @atakanbedel5418
    @atakanbedel5418 7 ปีที่แล้ว

    Not using

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

    thank u so much sir :)

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

    Thanks dude.

  • @user-ry7nl8ms4m
    @user-ry7nl8ms4m 6 ปีที่แล้ว +1

    Great 👍🏻

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

    thank you so much

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

      my pleasure.
      keep learning :)

  • @NoName-oq8ok
    @NoName-oq8ok 8 ปีที่แล้ว +2

    thanks thanks thaaaaanks

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

    thanks

  • @lokeshsrinivas2268
    @lokeshsrinivas2268 8 ปีที่แล้ว

    what is" return 0"for

  • @arunblaze8002
    @arunblaze8002 7 ปีที่แล้ว +4

    Can ternary operator have nested form like in if-else operator ?

    • @LearningLad
      @LearningLad  7 ปีที่แล้ว

      you can nest the ternary operator.

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

      Thank you Sir .

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

    which is more efficient to use...this one or if else?

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

      Generally, Ternary operators are preferred over if-else as they just round-up the whole nested if-else code in just 1 statement, and are easy to understand / less complicated.

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

    Sir, which software do you use to run these kind stuffs???

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

      i'm using codeblocks ide

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

    shukria

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

    which editor do you use?

  • @rectuserectus6164
    @rectuserectus6164 8 ปีที่แล้ว +4

    Great video! Whats the name of the program you use to write cpp?

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว

      +Rectus Erectus
      im using codeblocks ide :)

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

      Thanks!

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

      ***** I am experiencing an issue with codeblocks. whenever I press build and run, it doesn't do anything.

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว

      +Rectus Erectus
      what error you are getting????
      did you installed codeblocks along with mingw or what???

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว

      +LearningLad
      i mean to say did u get any warning etc????

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

    Thank you for the tutorials. You are awesome tutor.

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

      my pleasure.
      keep Learning :)

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

    Can you use this method to make nested if...else statements? It seems like you can, you just have to make another evaluating expression after the ':'. Or, am I wrong about this. The only thing I see is that it might get confusing.

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

      yes we can use them. you can avoid the confusion if you indent the code properly.

  • @informativecontent4778
    @informativecontent4778 7 ปีที่แล้ว

    thanks
    but u should also help us understand other ways do the same thing with ternry operators

  • @vishwasrahane8252
    @vishwasrahane8252 5 ปีที่แล้ว

    Used ternary statement in cout

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

    Bro can we use this in c

  • @manjuelaiya8597
    @manjuelaiya8597 7 ปีที่แล้ว

    n=100
    n-95?(n

  • @lokeshbajracharya5190
    @lokeshbajracharya5190 8 ปีที่แล้ว +4

    hey :)
    What if we have more than two conditions? like If, else if and else? could you please explain?

    • @bhonysingh9340
      @bhonysingh9340 7 ปีที่แล้ว

      reply anil plzz

    • @kleozane2781
      @kleozane2781 7 ปีที่แล้ว

      Use if - else if - else syntax

    • @aura9654
      @aura9654 6 ปีที่แล้ว

      else is always last as elif is a second if

  • @zefourthreich1744
    @zefourthreich1744 7 ปีที่แล้ว

    btw u can do // to write a comment

  • @coralmary35
    @coralmary35 9 ปีที่แล้ว +2

    how to use ternary operator for more than 2 variables :D

    • @LearningLad
      @LearningLad  9 ปีที่แล้ว +4

      coral
      i think you are asking about using 2 or more variables to form the condition.
      Use the logical and comparison operators in the condition.
      use parenthesis to group it.
      example
      #include
      using namespace std;
      int main()
      {
      int mark, avg;
      cout 20) ? cout

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

      thank you so much... that's what exactly I was looking for.... I always have problem with the parenthesis.... thanks again :)

    • @LearningLad
      @LearningLad  8 ปีที่แล้ว

      coral :)

  • @Freakinsexy778
    @Freakinsexy778 6 ปีที่แล้ว +2

    Good tutorial, it helps a lot. But perhaps you could have a tutor for teaching you better English XD. Sorry no offense meant by it, but instead of saying "You are passed in exam" and "You are failed in exam", English speakers would say "You have passed the exam" and "You have failed the exam"

    • @LearningLad
      @LearningLad  6 ปีที่แล้ว

      its ok.
      i get it.
      i'm working on it :)

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

      Imagine giving these tutorials in Hindi when your first language is English. That is the equivalent of what this guy is doing. Pretty amazing accomplishment, actually! :)

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

    sir you are right but you are passed in exam is not correct grammer lol

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

      i'm trying to improve.
      English is my 3rd language :)

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

      @@LearningLad You know three that's impressive. I want to learn a second one day.

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

      awesome :)

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

    //done
    #include
    using namespace std;
    int main()
    {
    int mark;
    cout > mark;
    mark >=45 ? cout

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

    can we use && / || operator in expn ???????
    (means Two conditions)