Question

In the code given below, how many times the cout statement is executed? for (int x = 0; x< 10; x++) for (int y=0; y < 10; y++

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

Ans--> In nested for loops the for each value of outer loop the inner loop runs from initial to its final condition.

As we can see here is 3 nested for loops for each value of x the for loop on variable y will run from 0 to 9 i.e 10 times. similarly for each value of variable y the for loop on variable z will run from 0 to 10 times i.e 11 times.

So inner for loop on z runs =11 times.

Inner for loop on y runs =10 times

Outer for loop on x runs=10 times

Total number of times cout statement is executed= 11×10×10

=1100 times.

In support of answer the above code snippet is implemented in program and output is no of times the loop runs.

edit with the bed and white de Process exited after 0.01428 seconds Press any key to continue

Add a comment
Know the answer?
Add Answer to:
In the code given below, how many times the cout statement is executed? for (int x...
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
ADVERTISEMENT