1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

# Consider the following C code segment. for (i = 0; i < n; i ++) { for (j = 0; j < n; j ++) { if (i % 2) { x + = (4 * j + 5 * i); y + = (7 + 4 *j); } } } which one of the following is false?

A
The code contains loop invariant computation
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
There is scope strength reduction in this code
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
There is scope of dead code elimination in this code
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
There is scope of common sub-expression elimination in this code
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

## The correct option is C There is scope of dead code elimination in this code(a) i%2 is inner loop invariant, it can be moved before inner loop. (b) 4*j is common sub-expression apeared in two statements. (c) 4*j can be reduced to j<<2 by strength reduction (d) There is no dead code in given code segment. So there is no scope of dead code elimination in this code. Hence only option (d) is FALSE.

Suggest Corrections
1
Join BYJU'S Learning Program
Related Videos
MATHEMATICS
Watch in App
Explore more
Join BYJU'S Learning Program