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;...
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...
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 <<...
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;...
points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...
Question 23 (1 point) What is the output of the following code snippet? int[] myarray = {62, 33, 5, 27, 41, 8, 39, 9); System.out.println(myarray[2]); System.out.println(myarray[6]); Blank # 1 Blank # 2 A/
How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...
Please answer both questions thank you. Question 52 (1 point) What is the output of the code snippet given below? String s = "abcde"; int i = 1; while (i < 5) { System.out.print(s.substring(i, i + 1)); i++; Question 50 (1 point) How many times will the output line be printed in the following code snippet? Please enter your answer as an integer. for (int i = 0; i < 3; i++) { for (int j = 1; j <...
Hello, please EXPLAIN how you got your answer. Thank you! int x = 1 int j; for (j=0; j <=2 ; j++) x = x * j ; cout << x << endl; What is the output of the C++ code above? Answer: A) 0 B) 1 C) 2 D) 3