Question

1. (TCO 1) What is the output of the following C++ code? int list[5] = {0,...

1. (TCO 1) What is the output of the following C++ code?

int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j < 5; j++)
     cout << list[j];

(Points : 4)

        0 1 2 3 4
        0 5 10 15
        0 5 10 15 20
        5 10 15 20

Question 2.2. (TCO 1) What is stored in alpha after the following code executes?

int alpha[5] = {0};
int j;
for (j = 0; j < 5; j++)
{
      alpha[j] = j + 5;
      if ( j % 2 == 1) //see if j is an even number
           alpha[j - 1] = alpha[j] + 2;
} (Points : 4)

        alpha = {5, 6, 7, 8, 9}
        alpha = {5, 6, 10, 8, 9}
        alpha = {8, 6, 7, 8, 9}
        alpha = {8, 6, 10, 8, 9}

Question 3.3. (TCO 1) What is the output of the following C++ code?

int alpha[5] = {2, 4, 6, 8, 10};
int j;
for (j = 4; j >= 0; j--)
     cout << "alpha[" << j << "] = " << alpha[j] << endl;

(Points : 4)

        2 4 6 8 10
        4 3 2 1 0
        8 6 4 2 0
        10 8 6 4 2

Question 4.4. (TCO 1) Which of the following about arrays as function parameters is true?
(i) Arrays are passed by reference only.
(ii) When we declare an array as a formal parameter we do not attach & after the data type of the array component. (Points : 4)

        Only (i)
        Only (ii)
        Both (i) and (ii)
        None of these

Question 5.5. (TCO 1) Consider the following statement:
double alpha[10][5];
The number of components of alpha is _____. (Points : 4)

        15
        50
        100
        150

Question 6.6. (TCO 1) Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int? (Points : 4)

        int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};
        int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};
        int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5};
        int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

Question 7.7. (TCO 1) Given the following declaration:
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fifth row of sale? (Points : 4)

        sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[5][j];
        sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[4][j];
        sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][4];
        sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][5];

Question 8.8. (TCO 1) Given the following multidimensional array declaration, how many elements exist in the array?
double neoMatrix[4][5][6]; (Points : 4)

        456
        60
        15
        120

Question 9.9. (TCO 2) In C++, class is a reserved word that defines (Points : 4)

        a data type.
        an object type.
        a variable.
        an enumeration.

Question 10.10. (TCO 2) In a class, all function members (Points : 4)

        must be public and all member variables must be private.
        must be public and all member variables must be public also.
        and member variables can be either public or private.
        must be private and all member variables must be public.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
1. (TCO 1) What is the output of the following C++ code? int list[5] = {0,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 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...

  • What does the following code output? int[] array = { 1, 4, 3, 6, 8, 2,...

    What does the following code output? int[] array = { 1, 4, 3, 6, 8, 2, 5); int sum = array[0]; Il scan the array for (int i=0; i < array.length; i++) { if ( array[i] > sum) sum = array[i]; 3 System.out.println( sum );

  • What is the output from each of the following segments of C++ code? Record the output...

    What is the output from each of the following segments of C++ code? Record the output after the “Answer” prompt at the end of each program fragment. Assume all variables have been suitably declared. (Each problem is worth 3 points.) 1. for (int j = 25; j > 16; j -= 3)        cout << setw(5) << j;     Answer: 2. int sum = 0;       for (int k = -2; k <= 2; k++)         sum = sum +...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • 1. (TCO 7) Which of the following statements are true? (Points : 5)        Interfaces contain...

    1. (TCO 7) Which of the following statements are true? (Points : 5)        Interfaces contain one and only one implemented method, a constructor.        Interfaces are defined inside an abstract class.        All methods defined in an interface must be implemented when used by another class.        A true object-oriented design must contain as least one interface. Question 2. 2. (TCO 7) In an object-oriented program, methods with no implementation might be found in an _____ and/or a(n) ______....

  • Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() {...

    Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() { int[][] array2D = new int[3][2]; for (int i = 0; i < array2D.length; i++) { for (int j = 0; j < array2D[0].length; j++) { array2D[i][j] = (i+j)%2; } } return array2D; فه public static void main(String[] args) { int[][] a = doStuff(); مہ سره Q21.1 What are the contents of array a? 6 Points Write your answer as if printing the elements row-by-row....

  • 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 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • what is the output of the following code segment? C++ g. int arr[3][4]; for (int 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;...

  • Computer Science - Java Explain the code step by step (in detailed order). Also explain what...

    Computer Science - Java Explain the code step by step (in detailed order). Also explain what the program required. Thanks 7 import java.io.File; 8 import java.util.Scanner; 9 import java.util.Arrays; 10 import java.io.FileNotFoundException; 12 public class insertionSort 13 14 public static void insertionSort (double array]) 15 int n -array.length; for (int j-1; j < n; j++) 17 18 19 20 21 double key - array[j]; int i-_1 while ( (i > -1) && ( array [i] > key array [i+1] -...

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