Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started