In the following Pascal program segment, what is the value of X after the execution of the program segment?
X := -10; Y := 20; If X > Y then if X < 0 then X := abs(X) else X := 2*X;
Answer of $X$ remains unchanged. As the if condition becomes false.
X := -10
Answer is C . This is classic example of $if-else$ issue. Always $else$ matches for nesting to the closest $if$ in $C$ Programming & Pascal . https://en.wikipedia.org/wiki/Dangling_else
if (x>y) { if (x<0) x=abs(x) else x=2*x }
@Ayush Upadhyaya
I havenot got your point
always try to match else with last unmatched if condition.
means?