Ask Question

What is the value of count after this nested FOR loop executes fully.

int count = 0;

for (int row = 4; row = < 15; row++)

for (int col = 0; col < 13; col = col + 2)

{

count+=2;

}

+1
Answers (1)
  1. 28 July, 09:34
    0
    168 (although the = < must be corrected to <=)

    Explanation:

    int count = 0;

    for (int row = 4; row < = 15; row++)

    for (int col = 0; col < 13; col = col + 2)

    count+=2;

    The inner for loop runs 7 times (for col = 0,2,4,6,8,10,12). Anything higher is not less than 13. Therefore the inner loop increments count by 2 seven times, i. e. it increments count by 14.

    The outer for loop runs 12 times (for row = 4,5,6,7,8,9,10,11,12,13,14,15).

    If the count is incremented by 14 twelve times, you are incrementing it by 14*12 = 168.

    Therefore the count goes from 0 to 168 after the nested loops.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is the value of count after this nested FOR loop executes fully. int count = 0; for (int row = 4; row = < 15; row++) for (int col = 0; ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers