previous | start | next

Self Check

  1. How would you modify the nested loops so that you print a square instead of a triangle?
  2. What is the value of n after the following nested loops?
    int n = 0;
    for (int i = 1; i <= 5; i++)
    for (int j = 0; j < i; j++)
    n = n + j;

previous | start | next