Ask Question
2 July, 04:08

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. 2 July, 07:46
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers