Question

PART A: Predict how many lines of output will be displayed by the following program fragment:...

PART A: Predict how many lines of output will be displayed by the following program fragment:

i = 0 ​​

do

{

​​for (j = 0; j < 4; j = j + 1)

​​printf("%d\n", i + j);

​​i = i + 1;

​​}

while (i < 5);

PART B: Then write either a C or a C++ program to verify your prediction. ​​

I know it will output 20 lines, the full C++ code is what I need.

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

Following is a full code written in c++

#include<iostream>

using namespace std;

int main()
{
int i = 0, j;
do
{
for(j = 0;j < 4 ;j = j+1)
cout<<i+j<<endl;
i = i + 1;
}while(i < 5);
return 0;
}

OutPut :-

Add a comment
Know the answer?
Add Answer to:
PART A: Predict how many lines of output will be displayed by the following program fragment:...
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