Question

help

What is the output of the code snippet below? int [ ] [ ] numarray = t 8, 7, 6, 1 0, 0, 0 li System.out.print (numarray [0] [0]) System.out.print (numary System.out.print (numarray to1 to array 1] to]); a) 00 b) 87 c) 80 d) 08

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

for the first program:

output is c) 80

in 2D array elements are arranged as follows:

numarray[0][0]=8, numarray[0][1]=7 numarray[0][2]=6

numarray[1][0]=0, numarray[1][1]=0, numarray[1][2]=0

for the second program

Ans is a) 2 4 7 11 16 22

because

in 1st iteration:

initially s=n=1. Inside loop s becomes equal to 2=s+n and n gets incremented by 1

and while condition get satisfied

in 2nd iteration: n=2 so s=2+2=4 and n gets incremented by 1 and while condition gets satisfied.

in 3rd iteration: n=3 so s=4+3=7 and n gets incremented by 1 and while condition gets satisfied.

in 4th iteration: n=4 so s=7+4=11 and n gets incremented by 1 and while condition gets satisfied.

in 5th iteration: n=5 so s=11+5=16 and n gets incremented by 1 and while condition gets satisfied.

in 6th iteration: n=6 so s=16+6=22 and n gets incremented by 1 and while condition gets dissatisfied

thus program terminates.

Add a comment
Know the answer?
Add Answer to:
help What is the output of the code snippet below? int [ ] [ ] numarray...
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
  • 51. What is the output of the following code snippet? int number = 0; int ptr_num...

    51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = &num; num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 ะก. 30 15 d. 30 30 Answer: 53. What is the...

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • 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) What output does this loop generate? int j = 1; do { int value = j * 2; j++; cout << value << ", "; } while (j <= 5); 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...

  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    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...

  • QUESTION 10 What will be the output of following code snippet? char *str; str = "%s";...

    QUESTION 10 What will be the output of following code snippet? char *str; str = "%s"; printf(str, "S"); A. S B. Garbage Value C. Compile-time Error D. Run-time Error 4 points    QUESTION 11 What will be the output of the following statements assuming that the array begins at the memory address location 7002 and size of an integer is 4 bytes? int a[3][4] = { 1, 2, 3, 4,                     5, 6, 7, 8,                     9, 10, 11, 12 }; printf("%d,...

  • (a)How many times does the code snippet given below display "Hello"? int x = 1; while...

    (a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) {    System.out.println ("Hello");    x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) {    sum = sum + i;    i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...

  • Consider the following C++code snippet and what is the output of this program? # include<iostream> using...

    Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...

  • Question 36 (1 point) What is the output of the code snippet given below? String s...

    Question 36 (1 point) What is the output of the code snippet given below? String s = "magnificent"; int i = 1; do { if (i > 2) System.out.print(s.substring (1, i)); } i++; } while (i < 5);

  • QUESTION 8 What (if anything) will be the output of the following code: int count =...

    QUESTION 8 What (if anything) will be the output of the following code: int count = 3; while (count++ <= 6) { System.out.print(++count + " "); } 3 4 5 6 4 5 6 7 3 4 5 6 7 5 7 4 6 The above code contains a syntax error and will not run. 8 points    QUESTION 9 What (if anything) will be the output of the following code: int count = 0; while (count < 5) {...

  • Question 23 (1 point) What is the output of the following code snippet? int[] myarray =...

    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/

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