Please, explain your answer clearly (step-by-step)
int j = 1;
do
{
int value = j * 2;
j++;
cout << value << ", ";
}
while (j <= 5);
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);
}
}
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]);
}
}
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++;
}
}
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?
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

Please, explain your answer clearly (step-by-step) What output does this loop generate? int j = 1;...
Please explain clearly your answers (step by step): 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);...
Please, explain clearly each line of code with your answers. Question 1 Consider the following code snippet: int ctr = 0; int myarray[3]; for (int i = 0; i < 3; i++) { myarray[i] = ctr; ctr = ctr + i; } cout << myarray[2]; What is the output of the code snippet? Question 2 Consider the following code snippet: int cnt = 0; int numarray[2][3]; for (int i = 0; i < 3; i++) { for (int j =...
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4}; int *p; p = arr + 3; *p = 5; printf("%d\n", arr[3]); A....
QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...
1)What is the output of the following code: int i = 10; do { cout << i; i++; } while (i < 5); cout << "-done"; 2)What is the output of the following code (note there are no endl's, all output is on single line)? for (int i = 1; i <= 3; i++) { cout << '('; for (int j = 0; j < (i*2); j++) cout << 'x'; cout << ')'; }
howthe output of the following 4 program segments (a) const int SIZE=8; int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8}; int index; index=0; res = values[index]; for (int j=1; j<SIZE; j++) { if (values[j] > res) { res = values[j]; index = j; cout << index << res << endl; } } cout <<...
Language is C++ Complete the following Review Questions: 1. This is a control structure that repeats a group of statements in a program? a. loop b. switch c. main() function d. compiler 2. In the expression number++,the ++operator is in what mode? a. Prefix b. Pretest c. Postfix d. Posttest 3.This is a variable that controls the number of iterations performed by a loop. a. Loop control variable b. Accumulator c. Iteration register variable d. Repetition meter 4. The do-whileloop...
1.The following statement gets an element from position 4 in an array named myArray: x = myArray[4]; What is the equivalent operation using an array list named list.? A x = list.get(); B x = list.get(4); C x = list.get[4]; D x = list[4]; 2.Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>(); int data; Scanner in = new Scanner(System.in); for (int i = 0; i < 5; i++) { data = in.nextInt(); num1.add(data); if (data == 0 &&...
#include <iostream> #include <string> using std::string; using std::cout; using std::endl; void testAnswer(string testname, int answer, int expected) { if (answer == expected) cout << "PASSED: " << testname << " expected and returned " << answer << "\n"; else cout << "FAILED: " << testname << " returned " << answer << " but expected " << expected << "\n"; } // Implement printArray here void printArray(int array[],int b) { for(int i = 0; i<b;i++) { std::cout<< array[i] << "...
what is the output of the following code segment?
C++
g. int arr[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) arr[i][j] =i*4 + j; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) cout << arr[i][j] << " "; h. int next(int & x) { x= x + 1; return (x + 1); int main() { int y = 10;...