Question: while and for loops are technically equivalent, and based on the usage in the program using one may be more convenient to the programmer than

while and for loops are technically equivalent, and based on the usage in the program using one may be more convenient to the programmer than the other. Every while loop can be written as a for loop, and vice versa. We will first practice a little with these and then move on to some programs! Re-write the following for loop using a while loop:

int i=0; for (i=0; i<100;i++) { SOME STATEMENTS; }

then

Re-write the following while loop using a for loop.

int a = 100; while (a<=0) { SOME STATEMENT; a-=2; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!