• What is a For Loop

    Developer Discussion
    21
    3 Votes
    21 Posts
    2k Views
    ObsolesceO

    I did some experimenting... but it's not always the case, it depends on what you are doing. But doing this with simple counting results:

    b3b9a87e-cb8d-4e6f-8edb-dd29ffc719b2-image.png

    And for fun lol....

    eb24b287-1c66-4c93-8949-85d9f083eab7-image.png

  • 0 Votes
    2 Posts
    1k Views
    lanceL

    I ended up finding that if I add another for statement and nested in the first for loop and then cout some blank spaces I was able to achieve what I was looking to do. Below is what I had to do.

    for(i = 0; i < num_rows; i++) { for(j = 0; j < num_cols_1; j++) { // print j'th element in i'th row of array 1 } // print some spaces for(j = 0; j < num_cols_2; j++) { // print j'th element in i'th row of array 2 } }