Question

1. Write a for loop that prints the sum of all positive even integers less than...

1. Write a for loop that prints the sum of all positive even integers less than 200. Assume that variables i and sum are already declared.

2. Write a while loop that prints the sum of all positive odd integers less than 100. Assume that variables i and sum are already declared.

3. Write a do-while loop that prints the sum of all positive multiples of 3 less than or equal to 150. Assume that variables i and sum are already declared.

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

\color{blue}\underline{1:}

for (i = 0; i < 200; i += 2) {
    sum += i;
}
printf("%d\n", sum);

\color{blue}\underline{2:}

i = 1;
while (i < 100) {
    sum += i;
    i += 2;
}
printf("%d\n", sum);

\color{blue}\underline{3:}

i = 0;
do {
    sum += i;
    i += 3;
} while (i <= 150);
printf("%d\n", sum);
Add a comment
Know the answer?
Add Answer to:
1. Write a for loop that prints the sum of all positive even integers less than...
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