Добавить
Уведомления

operator precedence in c++ | associativity of operators in c++

Operator precedence and Associativity Precedence Operator Precedence is the characteristics of operators that determine the evaluation order of operators in absence of brackets. Associativity Associativity is only used to determine which operator is evaluated first when two operator of same precedence are appeared together in expression. For example: a+b*c In the above example precedence of * is higher than the +, so first * is solved then + is solved. a-b+c In the above example the precedence of both + and – is same, so now they are solved by using their associativity, the associativity of both – and + is from left to right, so first – is solved than the + is solved. Example: int a=10+2/3*4; what will be value of a? +, / , * According to Highest Precedence / The remaining expression 10+0*4 Then * is solved so 10+0 Then + is solved 10 Then assignment is done so a will store 10. int a=10+2|8&5; + is solved, remaining expression is a= 12 | 8 & 5 & is solved, remaining expression is a= 12 | 0 | is solved , remaining a=12 int a=12&2+3/2%10-5; solve this and post the result. Download operator precedence table by clicking this link https://tinyurl.com/yakjlg73 #c++_by_tarun_sir #tarun_sir #C++ #tarun_sir_c++ #c++_video_9 #associativity_of_operators_in_c++ #c++_tutorial #operator_precedence_in_c++

Иконка канала Видео-планета
5 подписчиков
12+
17 просмотров
2 года назад
12+
17 просмотров
2 года назад

Operator precedence and Associativity Precedence Operator Precedence is the characteristics of operators that determine the evaluation order of operators in absence of brackets. Associativity Associativity is only used to determine which operator is evaluated first when two operator of same precedence are appeared together in expression. For example: a+b*c In the above example precedence of * is higher than the +, so first * is solved then + is solved. a-b+c In the above example the precedence of both + and – is same, so now they are solved by using their associativity, the associativity of both – and + is from left to right, so first – is solved than the + is solved. Example: int a=10+2/3*4; what will be value of a? +, / , * According to Highest Precedence / The remaining expression 10+0*4 Then * is solved so 10+0 Then + is solved 10 Then assignment is done so a will store 10. int a=10+2|8&5; + is solved, remaining expression is a= 12 | 8 & 5 & is solved, remaining expression is a= 12 | 0 | is solved , remaining a=12 int a=12&2+3/2%10-5; solve this and post the result. Download operator precedence table by clicking this link https://tinyurl.com/yakjlg73 #c++_by_tarun_sir #tarun_sir #C++ #tarun_sir_c++ #c++_video_9 #associativity_of_operators_in_c++ #c++_tutorial #operator_precedence_in_c++

, чтобы оставлять комментарии