mardi 31 mars 2015

c# loop assignment for my programming class

i have the following question for one of my assignments for my programming class and was wondering if somebody could help and explain the answer for me. We just started with loops and the book for the class isnt too helpful... the question is:


Study the following block of code carefully. When you submit your lab, add a comment to your submission that answers the following questions about this code:



for (int j = 0; j < 3; j++)
{
for (int i = 0; i < 3; i++)
{
if ( block [i] > block [i+1])
swap (ref block [i], ref block [i + 1]);
}
}


(1) When the code above is executed, how many times is this statement executed?



if ( block [i] > block [i+1])

Aucun commentaire:

Enregistrer un commentaire