Question

Please, explain your answer clearly (step-by-step) What output does this loop generate? int j = 1;...

Please, explain your answer clearly (step-by-step)

  1. What output does this loop generate?

int j = 1;

do

{

int value = j * 2;

j++;

cout << value << ", ";

}

while (j <= 5);

  1. What is the output of the following code snippet?

int my_fun (int A[], int size)

{

  int result = 0;

  for (int i = 0; i < size; i++)

  {

   result = result + A[i];

  }

  return result;

}

int main()

{

  int myarr[10] = { 5, 6, 10, 1, 2, 4, 8, 1, 2, 1 };

  for (int i = 0; i < 3; i++)

  {

   cout << my_fun(myarr, i);

  }

}

    1. No output
    2. 0511
    3. 056
    4. 000
  1. What is the output of the following code snippet?

int my_fun(int A[], int size)

{

int result = 0;

for (int i = 0; i < size; i++)

{

   result = result + A[i];

}

return result;

}

int main()

{

  int myarr[10] = { 2, 4, 10, 1, 2, 4, 8, 1, 2, 1 };

  for (int i = 0; i < 3; i++)

  {

   cout << my_fun(myarr, myarr[i]);

  }

}

  1. 026
  2. 6435
  3. 61735
  4. 600

Consider the following code snippet:

int cnt = 0;

int numarray[2][3];

for (int i = 0; i < 3; i++)

{

  for (int j = 0; j < 2; j++)

  {

    numarray[j][i] = cnt;

    cnt++;

  }

}

  1. What is the value of numarray[1][2] after the code snippet is executed?
    1. 2
    2. 5
    3. 3
    4. 4

5) Consider the following code snippet:

int cnt = 0;

int myarray[4][5];

for (int i = 0; i < 5; i++)

{

  for (int j = 0; j < 4; j++)

  {

    myarray[j][i] = cnt;

    cnt++;

  }

}

What is the value of myarray[1][2] after the code snippet is executed?

  1. 8
  2. 9
  3. 19
  4. 11
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please do understand my concern, as per Chegg guidelines we are supposed to answer the first question if there is more than one question in a post, your downvote effects my career a lot, if I get a downvote for a wrong answer or incomplete answer I will accept it. Please give a positive rating

Add a comment
Know the answer?
Add Answer to:
Please, explain your answer clearly (step-by-step) What output does this loop generate? int j = 1;...
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