Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions