Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. True or false? In C++, Cstring are the only kind of array for which there are

ID: 3608891 • Letter: 1

Question

1.       True or false? In C++, Cstring are the only kind of array for which there are aggregateconstants.

A)     True

B)      False

2.       Unlike other C++ arrays,a C string need not be output by the programmer one array elementat a time.

A)     True

B)      False

3.       In a data structure,components are said to be _______________ if they are all of thesame data type.

4.       Using a C++ standardlibrary routine, write a function call that copies the C string inthe array myString to the array youString.

5.       Using a C++ standardlibrary routine, write a function call that determines the lengthof C string in the array someString.

6.       An individual componentof a one-dimensional array is accessed by using a(n) ____________in square brackets to specify the component’s position withinthe array.

7.       What is the output of thefollowing program fragment?

Int gamma[3] = {5,10,15};

Int I;

For (i=0; i<3; i++)

Cout << gamma[i] << ‘ ‘;

8.       Write a statement todeclare an array alpha and initialize its components to 10,20, and30.

Int arr[5];

Int I;

For (I = 0; i<5; i++)

{

Arr[i] =i+2;

If (i>=3)

Arr[i-1]=arr[i] +3;

}

What is contained in arr[1]?

10.   What is the output of the following programfragment ?

Int alpha[5] = {100, 200, 300, 400, 500};

Int I;

For (i=4; i>0; i--)

Cout << alpha [i] << ‘ ‘;

11.   Given a 5000-elemnt, one-dimensional array beta,write a code fragment that could be used to print out the values ofbeta[0], beta[2], beta[4], and so forth.

(all variables are of type int.)

12.   True or false? dynamic data can be deallocatedduring program execution, but static data remains until the programterminates.

A)     True.

B)      False.

13.   True or false? If the new operator fails in itsattempt to allocate memory, the computer system aborts the programand prints an error message.

A)     True.

B)      False.

Explanation / Answer

7) you need to declare integer i. you have capital 'I'but lowercase 'i' needs to be declared. If that was simply atypo then the output is (there is a space after the lastvalue) 5 10 15 8) int alpha[3]={10,20,30}; 9) Arr[1] = 3 10) same as #7 on declaration, the output is however (there isa space after the last value) 500 400 300 200 100 11) int beta[5000]; 'Do whatever you want to fill it for(int i=0; i<5000; i=i+2) cout << beta[i] << " ";