Before Solving this Question You Should know : Operator Precedence and Priority Basic
Problem Statement 13 : Comparison operators/Relational operators
Options : Guess the Output#include<stdio.h> void main() { int num1=10,num2=20,num3; num3 = num1 > num2 && num2 > num1; printf("%d",num3); }
- 20
- 1
- 10
- 0
How ? Why ?num3 = num1 > num2 && num2 > num1;
- Above Expression Contain 3 Unique Operators [ > , && ,= ]
- Out Of them , Relational Operator has Highest Priority and .Assignment Operator [=] has Lowest Priority .
- So num1 > num2 will be executed First. Steps of Evaluation are as Follow -
Step 1 : num3 = num1 > num2 && num2 > num1 Step 2 : num3 = 0 && num2 > num1 Step 3 : num3 = 0 && 1 Step 4 : num3 = 0
0 Comments:
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email