Multiple choice technology programming languages

Which of the following statements are infinite loops? Select two correct answers

  1. for(int i=10;i>0;i-=-2);

  2. for(int i=0;i<012;i=i++);

  3. for(int i=0;i<0;i--);

  4. for(int i=0;(i++^--i)==0;i++);

  5. for(int i=010;i==10;i+=0);

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

Option B is infinite because i=i++ uses post-increment incorrectly - i is assigned its old value each time, so i stays 0 forever. Option D is infinite because the XOR (i++ ^ --i) compares a number with itself after increment/decrement cancel out, and any number XOR itself equals 0, making the condition always true. Option A terminates (i decreases from 10 to 2 in 5 steps). Option C never runs (condition false initially). Option E never runs (010 is octal 8, not 10).