59.7k views
0 votes
What will be the value of i after the C statements at the right have been executed

i = 3;

j = 10;

If ((3 * i) < j )

i = i + 2;

i = i +3;

User Matt Wiebe
by
7.2k points

1 Answer

5 votes

Answer:

8

Step-by-step explanation:

By presuming the given codes as below:

  1. int i = 3;
  2. int j = 10;
  3. if((3*i) < j)
  4. i = i + 2;
  5. i = i+3;

Firstly, we have i equal to 3. When the i is multiplied with 3 and check if it is smaller than j in the if statement (Line 4), it will return true and there i is incremented by two (Line 5). At this point the i = 3 + 2 = 5

Next i is incremented again by three in Line 7. Hence the final value of i = 5 + 3 = 8

User Gnomed
by
8.1k points