I need help with this textbook problem Thank you How many it

I need help with this textbook problem!

Thank you!

How many iterations will the following for loops execute? for (int i = 0; i

Solution

a) for(int i=1;i=20;i++) { }

executes 20 times.

b) for(int i=1;i<=20;i++) { }

  executes 20 times.

c) for(int i=5;i<20;i++) { }

  executes 15 times.

d) for(int i=20;i>0;i--) { }

  executes 20 times.

e) for(int i=1;i<20;i=i+2) { }

  executes 10 times.

f) for(int i=1;i<20;i*=2) { }

  executes 5 times.

I need help with this textbook problem! Thank you! How many iterations will the following for loops execute? for (int i = 0; i Solutiona) for(int i=1;i=20;i++)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site