Precedence and Associativity of Operators

Поділитися
Вставка
  • Опубліковано 7 лют 2025

КОМЕНТАРІ • 448

  • @hello_pi
    @hello_pi 4 роки тому +230

    Sir i am a cse student.... C is the 1st language for a cse student... I never forget you in my life

    • @MM44-t1e
      @MM44-t1e 14 днів тому

      Are you there, hello..!

  • @rahilumar3002
    @rahilumar3002 6 років тому +275

    Serving people is serving humanity....nice job luv it

  • @sdk28
    @sdk28 3 роки тому +136

    Relational > Equality operator:
    -> a c
    -> (a c)
    -> ((a c) (Associativity left-right)
    -> ((10 30)
    -> ((1)) == (1)
    -> 1 (true)
    True block will execute and TRUE will be printed

  • @purushothamchembeti8606
    @purushothamchembeti8606 6 років тому +524

    ans: True
    if(ac) given
    now have same precedence and their associativity is from left to right. initially ac also gives so now 1==1 which is true. == has low precedence compared to relational operators like >,>=,

    • @awsomeindia1295
      @awsomeindia1295 5 років тому +17

      How does ac also....plz reply I really need to know!!!!!!!!!!!!

    • @vishaliravichandran1314
      @vishaliravichandran1314 5 років тому +57

      @@awsomeindia1295 a

    • @awsomeindia1295
      @awsomeindia1295 5 років тому +16

      @@vishaliravichandran1314 thank u so much for explaining this😄😄

    • @rudraenterprises9005
      @rudraenterprises9005 5 років тому +5

      ​@@awsomeindia1295 sun if some thing is true it return 1

    • @adhitya946
      @adhitya946 4 роки тому +6

      In if condition it is true == true right??

  • @Prakhar_Choubey
    @Prakhar_Choubey 4 роки тому +90

    This guy is going straight to haven 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

  • @nagashayanreddy7237
    @nagashayanreddy7237 4 роки тому +44

    Answer is True. Seeing all the videos from East Africa , planning to appear for GATE in 2021. I am getting confidence by listening to your lectures. Thank you for your extraordinary work. :)

  • @Mytechielife
    @Mytechielife 6 років тому +48

    As relational operator has higher precedence a c turns to 1. Therefore 1==1. Hence true will be printed because if block will get executed.

  • @crypto_key_unlocked
    @crypto_key_unlocked 3 роки тому +1

    Thanks!

  • @sidans4325
    @sidans4325 2 роки тому +5

    It is the best channel to learn programming , i have watched many other channels , but i was not satisfied , but today I saw this channel and watched few videos and i am satisfied, now I have started to understand everything, thanks a lot

  • @renukadeviamalapurapu5662
    @renukadeviamalapurapu5662 5 місяців тому +2

    Sir, I am an avg student of cse 😢. I watched ur videos one day before exam the difference between ur channel and other channels is this channel provides deep concept , examples and questions for students. Thank you soo much sir.

  • @ChintanDhokai
    @ChintanDhokai 5 років тому +21

    a).True
    if(ac) given
    Now have the same precedence and their associativity is from left to right. Initially, ac also gives so now 1==1 which is true. == has low precedence compared to logical operators like >,>=,

  • @adi54113
    @adi54113 6 років тому +21

    Assignment answer is: true(as 1030 is also true and both cases are compared with equality operator so it is true.)

  • @AshishKumar-uw9xp
    @AshishKumar-uw9xp 3 роки тому +1

    Hello sir , I don't know u ll see my comment or not but u r god for the students who have eager to learn c language .

  • @krutarthpatel6537
    @krutarthpatel6537 4 роки тому +8

    Neso is best 👍

  • @vallipravallikaalluri
    @vallipravallikaalluri 6 років тому +4

    Tq so much i gone theough many websites but this is the 1 which fastly understand and went into my mind 😊😊

  • @rikkalarakeshreddy6466
    @rikkalarakeshreddy6466 4 роки тому +6

    very nice channel for learning each concept and logics in C programming.
    #include
    #define x printf("THANK U SO MUCH NESO ACADEMY")
    int main()
    {
    x;
    return 0;
    }

  • @rubitadas9382
    @rubitadas9382 4 роки тому +6

    you are great sir (: the way you are clear all concepts is awesome please upload more computer science subjects so that we people will helpful.

  • @APstudent-y6s
    @APstudent-y6s Рік тому +1

    16:10 and the answer comes out to be True
    thanks Neso❤

  • @rohitrout6450
    @rohitrout6450 4 роки тому +35

    Luv it..❤your content are really very easy to understand and that question u provide at the end...is a bliss..💓💓keep working like that

  • @Atharhashmisir
    @Atharhashmisir 5 років тому +1

    Thankyou very much. I have started C programming lectures in Hindi. you are helping me a lot.

  • @suryas1616
    @suryas1616 2 роки тому

    (ac) presedence:2
    == Presidence:3
    Answer: true

  • @hemalakshmi9044
    @hemalakshmi9044 3 роки тому +7

    a=10 , b=20 , c=30 , d=40 ;
    ( a c)
    Explanation :
    (10 30)
    Here first ...10

    • @maheshtech3241
      @maheshtech3241 2 роки тому

      Thanks for answering...it helped me to understand ❤️🤝

  • @sulthanamalick9308
    @sulthanamalick9308 5 років тому +7

    Sir please compelete the C programming series it will be useful for our placements....please sir. Your video are really good.Thank you so much sir..

  • @hello_pi
    @hello_pi 4 роки тому +8

    You are the real hero sir........ 🙏🙏🙏🙏🙏

  • @compangit1524
    @compangit1524 2 роки тому +3

    Comments for myself: Associativity is order of evaluation when expressions have the same precedence, could be left-to-right or vice versa. Postfix increment/decrement has greater precendence than prefix. Associativity of postfix operator is from left to right, while prefix is from right to left. Only the assignment, conditional, and unary operators have an associativity of right to left. Associativity only works of we have more than ONE operators of same precedence. If only one, the behavior is undefined and output is compiler dependent. For the assignment, the output is TRUE

  • @nforme7826
    @nforme7826 4 роки тому +3

    a30] which is true
    ac
    True==true
    So, output is true😊

  • @7Strigiformes
    @7Strigiformes 5 років тому +6

    Thanks a lot sir for these types of great videos...

  • @AbdElrahmanAmirMohamed
    @AbdElrahmanAmirMohamed 4 роки тому +2

    i can't know how can i thank you
    great content ..... thank you very much 💙💙💙💙💙💙

  • @sushmanthavala7813
    @sushmanthavala7813 3 роки тому +1

    You are the god for many students sir love you ❤️

  • @sohamshinde1258
    @sohamshinde1258 4 роки тому +2

    I just dont understand how the brains of the people who have disliked the vedio work, really I don't just get it. May be undertanding them is more complicated than C language.

  • @sukhbeersingh5811
    @sukhbeersingh5811 3 роки тому +1

    The output of the homework problem is TRUE.👍

  • @zeezoscode6954
    @zeezoscode6954 Рік тому

    The answer for the question is True. Thanks for the great explanation 😍😍

  • @hanivarsitha2505
    @hanivarsitha2505 3 роки тому +2

    Superb explanation 👍

  • @mauryaashish1865
    @mauryaashish1865 4 роки тому +2

    You are insane man!! 🔥🔥🔥

  • @ka7126
    @ka7126 3 роки тому +2

    Thank you so much, bro, you explain this so well; I'm set for success in my class moving forward

  • @lets___explore
    @lets___explore 6 років тому +2

    Ans is true....i understand the concept very well☺..thakiieeww soo mch...

  • @realgamerz5575
    @realgamerz5575 3 роки тому

    home works answer is true
    thank u so much to give such a great content free of cost

  • @MohitK96
    @MohitK96 6 років тому +6

    everyone underestimates precedence and associativity without knowing that they are the most important topics...

    • @waverache8296
      @waverache8296 5 років тому

      Right

    • @tawseeftaher4446
      @tawseeftaher4446 4 роки тому

      mohit,vai...
      i can't memotize this associativity & precedence table. Please help me, if possible

    • @hello_pi
      @hello_pi 4 роки тому +1

      @@tawseeftaher4446 practice bro... Do practice

  • @varunsamrutwar1966
    @varunsamrutwar1966 3 роки тому +1

    the ans is true ,
    explanation :-
    if(ac)
    {
    cout

  • @varunsharma2876
    @varunsharma2876 4 роки тому

    This the best channel👌👌👌

  • @udittiwari8409
    @udittiwari8409 4 роки тому +1

    this your video is best and is this is fully complete series for gate sir plz tell i am following your series

  • @saraiahd
    @saraiahd Рік тому

    if(ac) in this expression left to right associativity is there
    a30
    now 1==40 returns false means 0
    now 0>30 returns true means 1
    if(1) means true so TRUE will be the answer

  • @princeyaduvanshi9519
    @princeyaduvanshi9519 2 роки тому +2

    Very well understood everything. Thanks you sir 🤗🤗

  • @maneeshachandel8493
    @maneeshachandel8493 4 роки тому +1

    Thank you so much sir...you defined it with..minute details

  • @Tara_Sutar
    @Tara_Sutar 2 роки тому

    @ 14:28 example, Why is Neso Academy bring printed ?
    1) variable "a " is an type.
    2) The function is returning only 1 not Neso. and why does it return Neso ?

  • @ashishkhari5565
    @ashishkhari5565 2 роки тому

    True is the answer of the homework problem................

  • @namita6577
    @namita6577 5 років тому

    Ans will be true because having same precedence but due to left to right associativity . Here, ac also results 1 and then == will execute which prints true.

  • @samamostafa2299
    @samamostafa2299 4 роки тому

    1. we have a condition expression --> (a c)
    2. Relational precedence is higher than equality precedence therefore,
    . 'b' belong to '' operator ---> (d > c), which return TRUE
    . according to Associativity order Left to Right: (a C)
    3. finally Equality will be evaluated (1 == 1), therefore the if construct will return TRUE

  • @awsomeindia1295
    @awsomeindia1295 5 років тому +2

    Thank you so so so so so much sir....really helpful and detailed video

  • @apnakaamkaro2644
    @apnakaamkaro2644 5 років тому +4

    Thankyou For these Lectures Sir :)

  • @Xardas_
    @Xardas_ 2 роки тому

    Since the

  • @deepakbhardwaj3141
    @deepakbhardwaj3141 6 років тому +4

    U r awesome Sir doing a great job....

  • @saisahasra14
    @saisahasra14 4 роки тому

    Answer is True.
    Because ,d>c is true that is 1
    and a

  • @mohamedkhawaga8067
    @mohamedkhawaga8067 3 роки тому

    as per ac
    a belongs to
    so precednce applies
    (ac)
    in this case we have only one operator == so there is no need to apply associativity

  • @SsSs-nr2nt
    @SsSs-nr2nt 4 роки тому +2

    good initiative

  • @nishithbaravkar7549
    @nishithbaravkar7549 4 роки тому +1

    thanks for this wonderful video

  • @brotherinterest6912
    @brotherinterest6912 2 роки тому +2

    so what happen in the last question is that (ac). so there are 2 relational operator and 1 equality operator or u can say (a relational operator b equality operator d relational operator c). so relationall operator has higher precedence and it goes from left to right then (1030), 1030 that s also true (1) then 1==1 true == true that s also true, so TRUE

  • @shubhammahajan6696
    @shubhammahajan6696 6 років тому +6

    one video in 2 day means syllabus finish before gate 2019 we can expect with you thanks

  • @bhargavchowdary45
    @bhargavchowdary45 4 роки тому

    ans=true;
    #include
    int main()
    {
    int a=10,b=20,c=30,d=40;
    if (a c)
    {
    printf("true");
    }
    else
    {
    printf("false");
    }
    return 0;
    }

  • @kishanchaurasia2909
    @kishanchaurasia2909 4 роки тому +2

    Sir I have a doubt.
    Could you explain the reason for such behaviour.
    #include
    int main()
    {
    int a=10;
    int b= ++a + a++;
    printf("%d
    ",b);
    return 0;
    }
    Output : 23
    But expected answer is 22 because first postfix will be evaluated then prefix and sum and at last assignment
    b= 12+10
    Sir please explain this.

  • @nandinichaudhari4513
    @nandinichaudhari4513 2 роки тому

    Very nice explanation, my all doubts get clear.

  • @sanketkumar29
    @sanketkumar29 6 років тому +4

    Sir plz make videos on cmos basics and its gate implementation.🙏🙏
    Your videos are helping me alot thank you so much🙏🙏😊

  • @accessdenied9393
    @accessdenied9393 3 роки тому

    int main(void) {
    int a=10, b=20, c=30, d=40;
    int expr = (a c);
    printf("%s", expr ? "true" : "false");
    return 0;
    }
    In this example "true" get printed out. Because, "" operators take precedence over "==" operator, so both "" evaluated first then "==" operator:
    (10 30)
    Both (10 30) return true, which it is represented by 1 (or any non-zero), so the expression expanded like that:
    (1 == 1)
    Now because of (1 == 1) returns true (non-zero), "true" get printed, otherwise "false" keyword would have been printed.

  • @Foodfind217
    @Foodfind217 Рік тому

    Answer of the question of this lession:
    True

  • @382_alamin8
    @382_alamin8 2 роки тому

    So much attractive content thanks for it. Ans. True

  • @smrutiranjanmohanty21
    @smrutiranjanmohanty21 5 років тому +2

    Excellent

  • @natnaellegesse1881
    @natnaellegesse1881 3 роки тому +1

    (2+3)*5 =25 it is correct and it is called distributive property of multiplication over addition, 5*2+5*3=25
    ✔️

  • @s.saketh4725
    @s.saketh4725 Рік тому

    sir i have a doubt in 14:11 part why there is a 2 in both outputs but in the code there is no 2
    please answer my doubt

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 3 роки тому

    Tussi great ho Sir ji

  • @selvalakshmis.v4232
    @selvalakshmis.v4232 3 роки тому +1

    True
    Thank you, Sir

  • @Steeve.smoker
    @Steeve.smoker Рік тому

    Sir.u pin correct answers.and I enjoy ur series ❤❤

  • @vikramsingh-jb1xt
    @vikramsingh-jb1xt 6 років тому +2

    Don't know, because (a c) is also true and return non zero. And finally if(non zero == non zero) sometimes equal or not equal. Therefore I can't predict the answer all times. So it may be compiler dependent.

    • @prashant1206
      @prashant1206 6 років тому

      but in relational operator(==) non zero value is taken as true so, true(any non zero value)== true ,
      so result is true..

  • @khushiverma894
    @khushiverma894 4 роки тому +2

    At 11:52, in 3rd statement there are 2 operators of same precedence i.e. () nd consist higher precedence than + then associativity should be left to right and hence fun1() should be called first then why it is unpredictable...I don't know if it's silly bt I didn't get it.....plz explain

    • @SandhyaSingh-ms6br
      @SandhyaSingh-ms6br 4 роки тому +1

      See that statement very carefully, there are only two operators, () and +. There are two occurences of () but overall there are only two operators to work with, i.e, () and +
      Associativity comes into picture when there are two or more than two operators of SAME PRECEDENCE.
      By two ore more operators, it simply means two are more different operators of same precedence. Please make a note of this that two or more *different* operators but of same precedence, then associativity will decide which will be evaluated first.
      Do you get it now?
      And it's not silly, actually first look pe ye misconception hona is okay, ho jata hai

    • @khushiverma894
      @khushiverma894 4 роки тому

      @@SandhyaSingh-ms6br yeah got it...thanks😊

  • @shubhammahajan6696
    @shubhammahajan6696 6 років тому +55

    if u work like this so we'll no need of rbr sir paid lecture

    • @fun2shh899
      @fun2shh899 4 роки тому +3

      true bhai

    • @rishabhchakraborty2628
      @rishabhchakraborty2628 4 роки тому +1

      Exactly, his course is not worth in terms of depth. He just makes everything memorise.

    • @mrunmaidahare8477
      @mrunmaidahare8477 4 роки тому

      are these lectures better than rbr sir paid lecture? plz tell

  • @jeniferjenifer7752
    @jeniferjenifer7752 4 роки тому +1

    Super super,😍😍😍😍

  • @unknown-kn4uf
    @unknown-kn4uf 5 років тому +3

    @3:48 associativity of * is more than / you only told. Then why here you are saying that associativity of / is more than *

    • @AbbaJi-gm4vc
      @AbbaJi-gm4vc 5 років тому

      See again

    • @adeebalam2392
      @adeebalam2392 3 роки тому

      @@AbbaJi-gm4vc can you please explain I have the same doubt

  • @suryatomar1997
    @suryatomar1997 4 роки тому +1

    sir in expression (2+3)*5 ,we must have to solve bracket first then the multiplication should be done, isn't it?

  • @andlurimunireddy4622
    @andlurimunireddy4622 4 роки тому

    Ans is true.because in relational operators priority is ,=,==,=! . so according to this priority ans is considered as true

  • @adriancardosa2448
    @adriancardosa2448 4 роки тому

    Advance happy 1m subs ♥️ from Philippines

  • @nitishaagrawal8629
    @nitishaagrawal8629 6 років тому +1

    Sir ,Plz upload more videos on loops,arrays n all the topics of C language, U'r videos are helping me a lotttttt bcozz..Plz..

  • @manojbasam6732
    @manojbasam6732 5 років тому +1

    Great job sir

  • @RAHULTMNT100
    @RAHULTMNT100 5 років тому +1

    great video!

  • @kishanchaurasia2909
    @kishanchaurasia2909 4 роки тому +1

    Sir I have a doubt.
    int a= 10;
    int b=10;
    int c= a+ b+a++;
    Output : 30
    But if we follow precedence then first a++ will be solved and then sum will be solved and answer would be 31
    c= 11+10+10
    Sir please explain this.

    • @badxcode
      @badxcode 4 роки тому +1

      are you still here?
      according to postfix increment which was mentioned before, first the value of 'a' will be use in the equation then it will increment by '1'.
      so, here value of a = 10 is used in the equation first then after completing the equation and and returning value 30 to 'c', a will increment by 1.
      a will not increment first and be '11' then get used, it will be used first as '10' then after completing the equation a will increment by 1.
      print the value of a after the equation of c if that's correct or not.
      Hope you understood what I wanted to say ..!

    • @kishanchaurasia2909
      @kishanchaurasia2909 4 роки тому +1

      @@badxcode thanks

    • @kishanchaurasia2909
      @kishanchaurasia2909 4 роки тому +1

      @@badxcode please explain this one more
      int a=10;
      int c=a+a++;
      Output is 21
      Now if I follow what you said then it must 20 only please explain.

    • @badxcode
      @badxcode 4 роки тому +1

      @@kishanchaurasia2909 quite confusing.
      According to Neso, rule of postfix in equation is that it will use in equation first then it will increment by 1. (sorry, I talked about completing the equation. I was wrong. Completing the equation comes in light in terms of prefix increment/decrement in equation) You can see the details in video-24 in this playlist, in case you din saw.
      And with that explanation c=a+a++; seems right.
      Now about that previous question you asked I guess there's a trick behind that question which I, as a beginner won't be able to find out.
      I'm just as confused as you are right now.
      Anyway, if you find the answer, then please don't forget to share it here else I'll crack my head over and over.
      I hope sir see this problem and reply soon. Or anyone else who figured it out reply here.
      I guess I'm gonna post this problem on different programming groups in facebook to find out.
      Anyway, Thanks. You mentioned quite a tricky problem here.

    • @Tony-cw6om
      @Tony-cw6om 4 роки тому +2

      @@kishanchaurasia2909
      here in the expression c=a+a++ ...we have two operators one is '+' and another is '++'( postfix increment operator) .a postfix increment operator has higher precedence than the unary plus operator so.. in this expression,
      C=a+a++
      -firstly a++(postfix operator) will be evaluated, in this 1st 10 is assigned to a and then incremented ..as it is incremented the value of a changes to 11
      -hence 11 is substituted in place of a which is the left operand so.. 11 is added to 10 hence the output will be 21
      I.e , c=11+10
      c=21
      I hope you understand!!🙃🙃

  • @noone0978
    @noone0978 Рік тому

    true will be answer
    btw sir, do we have to learn the table?

  • @AbstractZeroData
    @AbstractZeroData 11 місяців тому

    if we consider () paranthesis as an operator then there is more than one operator in the expression fun1() + fun2()

  • @Official-tk3nc
    @Official-tk3nc 5 років тому +15

    Guys they are providing everything for free and some idots dislikes these types of videos. I think they need mental treatment

    • @manishsuthar597
      @manishsuthar597 4 роки тому +1

      They probably would be jealous teachers😟😕

    • @nihalpandey5675
      @nihalpandey5675 4 роки тому +1

      Bro you have just commented same thing in almost each lectures I have gone through. By the way those who r disliking may be having more knowledge but if you have more knowledge what the hell r u doing here😂

  • @swathik3491
    @swathik3491 5 років тому

    ac gives true and true = = true so its print True

  • @deepeshsunuwar1086
    @deepeshsunuwar1086 4 роки тому

    the answer is TRUE.
    BECAUSE the relational operators has more precedence than equality operators,
    so (ac), here same precedence so associativity is from left to right,
    hence both returns true which means 1==1 and it is also true so the final O/P is;
    T R U E.....................................

  • @qwertyuiopasdfghjkl4211
    @qwertyuiopasdfghjkl4211 6 років тому

    Output is true, because relation operater will return only true or false, here will perform because it is left to right associative both are returning true and both == same.

  • @mahtabalam5354
    @mahtabalam5354 5 років тому

    great teaching sir

  • @payalkumari3825
    @payalkumari3825 3 роки тому

    Explain various operators with its precedence in c.
    Explain various operators in c.
    Sir this two questions are same or different

  • @sspsuman
    @sspsuman 4 роки тому +2

    () has Left to Right associativity.
    So why not first fun1() then fun2() will execute always ??

    • @mr.knight8967
      @mr.knight8967 3 роки тому

      No man,
      When both have same precedence,
      Compiler work left to right so fun1() will execute first.

    • @duggirambabu7792
      @duggirambabu7792 2 роки тому

      @@mr.knight8967
      int a, b, c=3;
      a = b = c;
      Have same precedence.
      *It goes from Right to Left,* not Left to Right.

  • @criminalcoder6307
    @criminalcoder6307 3 роки тому

    True..
    As relational operators have higher precedence than equality operator.

  • @neerajnegi1447
    @neerajnegi1447 4 роки тому

    In the first example if fun is variable with value assigned to it as 0 then if the expression is like this " int var = fun++" then why the value
    of var becomes 0 as ++ has higher precedence than = so var should have the value of 1.

  • @shraddhaaasne3915
    @shraddhaaasne3915 4 роки тому

    sir please make more videos on basic c programming.

  • @mahavirsingh5790
    @mahavirsingh5790 5 років тому +5

    output is true

  • @rekxspein
    @rekxspein 5 років тому +1

    Bro I have a question, you said, "Precedence of Postfix increment / decrement is greater than prefix increment/ decrement"
    I think this is not true, prefixes are always performed first and assigned, rather than Postfixes.
    Correct me if I am wrong.

    • @kwynart6399
      @kwynart6399 5 років тому +1

      Did u solve this a+++b then you can understand

    • @tawseeftaher4446
      @tawseeftaher4446 4 роки тому

      @@kwynart6399 thank you, vai.
      it helped me a lot

    • @tawseeftaher4446
      @tawseeftaher4446 4 роки тому

      rajesh
      the video is correct brother

    • @johnbode5528
      @johnbode5528 4 роки тому

      Precedence only controls which operators are grouped with which operands; it does not control the order in which operands are evaluated. It doesn’t help that the behavior of the - and ++ operators are not straightforward.
      ++x _evaluates_ to x+1 - as a *side effect* it changes the value of x, but that side effect does not have to be applied immediately. If you write something like x = ++y, it’s *roughly* equivalent to writing
      tmp = y + 1
      x = tmp
      y = y + 1
      except that the order in which x and y are updated isn’t fixed. Similarly, x = y++ is roughly equivalent to
      tmp = y
      x = tmp
      y = y + 1
      with the same caveat that the order in which x and y are updated isn’t fixed.
      But yes, unary ++ has lower precedence than postfix ++. If such an expression were legal, ++x++ would be parsed as ++(x++). However, such an expression is *illegal* - the operand of the ++ operator (either form) must be an lvalue (something that can be the target of an assignment), but the result of x++ is not an lvalue.

  • @harshavardhankanoj6021
    @harshavardhankanoj6021 3 роки тому

    Why at the end 2 comes at the output of question at 14:38

  • @chinmaypatil1849
    @chinmaypatil1849 4 роки тому

    True is the answer 😁 thanks

  • @adhishravi20
    @adhishravi20 5 років тому

    Which is the best book to follow ?