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

Question 1. A return statement causes execution of a function to return to the t

ID: 3555438 • Letter: Q

Question

Question 1. A return statement causes execution of a function to

       return to the top of the loop.
       return to the top of main.
       return to the top of the function.
       terminate and return to where the function was called.

Question 2. What is the output of the following code?

void func(int x[ ])
{
x[0] = x[0] * 3;
x[1] = x[1] * 3;
x[2] = x[2] * 3;
}
int main( )
{
int x[ ] = {1, 2, 3};
func(x);
cout << x[0] << " " << x[1] << " " << x[2] << endl;
}

       1 2 3
       3 4 5
       3 6 9
       3 3 3

Question 3. The code below is an example of what type of function?

int abs(int num)
{
      if (num == 0)
            num = -num;
      return num;
}

       Value-returning
       Void
       Subroutine
       None of the above

Question 4. What is the range of valid subscripts for the following array?

char name[99];

       1 to 99
       0 to 98
       1 to 98
       0 to 99

Question 5. Given the following array declaration, if the array is stored starting at address 1000, what is the output of the following statement? Assume the code is for a 32 bit processor such as a Pentium.

double data[25] = {0.0};
cout << &data[10] << endl;

       0.0
       1080
       1010
       unknown

Question 6. Given the following code which fills the array with values,

int X;
int data[100];
for(int i = 0; i <= X; i++)
{
      data[i] = i;
}



what should the value of X be?

       100
       101
       99
       i

Question 7. The last data element in foo is _______.

const int MAX = 500;
double foo[MAX] = {0.0};

       foo[MAX]
       foo[500]
       foo[MAX - 1]
       None of the above

Question 8. For the array declared below, what is the sum of list[2] and list[3]?

int list[]= {1,2,3,4,5};

       5
       9
       3
       7

Question 9. A variable declared before all blocks in a program is

       visible to all functions defined in the program.
       visible only to main.
       visible only to the first block after it is declared.
       not visible to any functions; it will cause a compile error.

Question 10.  A C-Style string which is not null terminated will

       cause a compiler error.
       cause a run-time error when processed by the strcpy function.
       cause a linker error.
       produce a correct result when processed by the strlen function.

Question 11. Which of the following functions would correctly copy C string s2 to C string s1?

       strcpy(s2, s1) ;
       strcmp(s1, s2) ;
       strcpy(s1, s2) ;
       stringcopy(s2, s1) ;

Question 1. A return statement causes execution of a function to

       return to the top of the loop.
       return to the top of main.
       return to the top of the function.
       terminate and return to where the function was called.

Explanation / Answer

1  terminate and return to where the function was called.

2 3 6 9

3   Value-returning

4   0 to 98

5 1080

6 99

7 foo[MAX - 1]

8 7

9  visible to all functions defined in the program.

10 cause a run-time error when processed by the strcpy function.

11 strcpy(s1, s2) ;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote