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

1 Which one is the correct function definition? (a) void square(int &x) (b) squa

ID: 3552444 • Letter: 1

Question

1        Which one is the correct function definition?

(a)    void square(int &x)                      (b) square(int &x)

{                                                          {

           int y ;                                                   int y = x*x;

            y = x*x;                                               cout << y << endl;

            cout << y << endl;                                return y;

            return y;                                   }

}     

(c) int square(int &x)                         (d) void square(int &x)

{                                                          {

           int y ;                                                   int y = x*x;

            y = x*x;                                               cout << y << endl;

            cout << y << endl;                  }

}     

2        Given the following array declarations:

(1) double a[30];

(2) int s(6) = {1, 2, 3, 4, 5, 6};

(3)   int s[ ] = {1, 2, 3, 4, 5};

(4)   char[30] r;

(5)   int s[4] = {1, 2, 3, 4, 5};

(6)   char str[ ] =

Explanation / Answer


Answers:


1. (d) void square(int &x)

           {

          int y = x*x;

              cout << y << endl;

           }


2. (b)   Only (1), (3) and (6) are correct.


3. (c)    9.1


4. (c)    The array size used to declare an array may be any expressions.


5. (b)   3 5 7 4 6 8 5 7 9 6 8 10


6. (d)   a[0] = 1, a[1] =2, the rest are 0s.