Question

or (int i - 3; i<ll; i-i+2) Solution: cout< iend; i-i2 B) What will the following program fragment output? (2 points) int mai
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution A)

Initially i=3

Iteration Value of i i<10 Result of i<10 print i i=i*2 i=i+2
1 3 3<10 true 3 i=6 i=8
2 8 8<10 true 8 i=16 i=18
3 18 18<10 false,loop ends

Output:

3

8

Solution B)

Initially j=7, d=2 , sum=0

Iteration Value of j j>=0 Result of j>=0 sum=sum+d j=j-1
1 7 7>=0 true sum = 0 +2 =2 j = 7-1 =6
2 6 6>=0 true sum = 2 +2 =4 j = 6-1 =5
3 5 5>=0 true sum = 4 +2 =6 j = 5-1 =4
4 4 4>=0 true sum = 6 +2 =8 j = 4-1 =3
5 3 3>=0 true sum = 8 +2 =10 j = 3-1 =2
6 2 2>=0 true sum = 10 +2 =12 j = 2-1 =1
7 1 1>=0 true sum = 12 +2 =14 j = 1-1 =0
8 0 0>=0 true sum = 14 +2 =16 j = 0-1 =-1
9 -1 -1>=0 false, loop ends

output:

16

Add a comment
Know the answer?
Add Answer to:
or (int i - 3; i<ll; i-i+2) Solution: cout< iend; i-i2 B) What will the following...
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