Question

Which for loop has range of similar indexes of i used in: for (i =0; i<n; i++) for (i = n-1; i >= 0; i--) for (i = n-1; i >

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# STAY HOME # STAY SAFE

The range of values of i in for (i = 0; i<n; i++) if [0, n-1].

Option 1 :

for(i = n-1; i>=0; i--)

In this loop thr value of i starts from n-1 and decrements till 0 .

=> Therefore,the range of values of i is [0, n-1].

=> This option is correct.

Option 2 :

for(i = n-1; i>=0; i--)

In this loop thr value of i starts from n-1 and decrements till 0 .

=> Therefore,the range of values of i is [0, n-1].

=> This option is correct.

Option 3 :

for(i = n; i>=0; i--)

In this loop thr value of i starts from n and decrements till 0 .

=> Therefore,the range of values of i is [0, n].

=> This option is incorrect.

Option 4 :

for(i = n-1 ; i>0; i--)

In this loop thr value of i starts from n-1 and decrements till 1 .

=> Therefore,the range of values of i is [1, n-1].

=> This option is incorrect.

Add a comment
Know the answer?
Add Answer to:
Which for loop has range of similar indexes of 'i' used in: for (i =0; i<n;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT