152_Q_2_C - CSCI152CPossibleAnswersforQuiz2(9March)

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI 152   C           Possible Answers for Quiz 2 ( 9 March ) 1.  Given the following declarations:      int list[12] = { 4,  9,  1,  7,  3,  6,  2,  11,  12,  8,  5,  10 };             int n = 3;         0   1   2   3   4   5   6   7     8    9  10  11     Answer these questions,  using the original values  for each question:     a)  How many elements are there in list?   12     b)  What is the  subscript  (index) of the smallest  1 is the smallest element value           element value in list?   Subscript of 1 is 2     c)  What is the value of    list [n]  ?          list[3] is 7     d)  What is the value of    list [n] * 2  ?      list[3] * 2 is 7 * 2 is 14     e)  What is the value of    list [n + 2]  ?     list[3 + 2] is list[5] is 6 f)  Write a statement which will assign to the last          element a value which is twice the value of the           third  element. list[11] = 2 * list[2];     g)   How many  values are output by this loop:          for (n = 0; n < 12; n = n + 2) loop executes for n = 0,2,4,6,8,10                cout << list [n];                    so 6 values are output 2.  Given the declaration:   int anArray[MAX];   // MAX is defined as a constant
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/24/2011 for the course CSCI 1302 taught by Professor Harter during the Spring '11 term at Texas A&M University–Commerce.

Page1 / 3

152_Q_2_C - CSCI152CPossibleAnswersforQuiz2(9March)

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online