1

Consider the following function definition and variable declarations: void square(int &n){n= n*n;} int arr[] = {1,...

Question

Consider the following function definition and variable declarations: void square(int &n){n= n*n;} int arr[] = {1,...

Consider the following function definition and variable declarations:

void square(int &n){n= n*n;}

int arr[] = {1, 2, 3};

int number = 4;

Which of the following function calls are acceptable? (can have multiple answer)

a.square(1);

b.square(2);

c.square(arr[number]);

d.square(number);

What is the output of the following code segment?

int arr[] = {1, 4, 1, 0};

for (int i=0; i < 4; ++i)

    cout<<arr[i]*2;

a.1014

b.1 4 1 0 (space in between each number)

c.1410

d.0140

e.None of the above

Given array declaration int a[] = {1, 2, 3};, the value of a[3] is

a.1

b.2

c.3

d.Undefined (or out-of-bound error)

e.None of the above

Answers

Question 1:

Answer :

c.square(arr[number]);

d.square(number);

Explanation :

  • Here square(arr[number]); is acceptable but square(arr[4]) will be 0
  • square(number); will be 16 because square(4) will be 16

*********************************

Question 2:

Answer :e.None of the above

Explanation :

  • Here each element from the array will be multiplied by 2
  • hence the output will be 2820

************************************

Question 3:

Answer :e.None of the above

Explanation :Here a[3] will be 0 because array is defined with three elements and a[3] will be 0.

************************************


Similar Solved Questions

1 answers
Find the volume of the tetrahedron having the given vertices. (-6, -6, -5), (4, -6, -3),...
Find the volume of the tetrahedron having the given vertices. (-6, -6, -5), (4, -6, -3), (5, 4, -4), (0, 0, 10)...
1 answers
(20%) Problern 0: 1 he figure shows an electron passing between two charged metal plates that...
(20%) Problern 0: 1 he figure shows an electron passing between two charged metal plates that create a 98 NC vertical electric field perpendicular to the electron's original horizontal velocity. (These can be used to change the electron's direction, such as in an oscilloscope.) The initial s...
1 answers
How do you simplify #(2+3)^2 + (3+1)^2# using PEMDAS?
How do you simplify #(2+3)^2 + (3+1)^2# using PEMDAS?...
1 answers
How do you add #1 2/5 + 4 4/10#?
How do you add #1 2/5 + 4 4/10#?...
1 answers
1. There are many simple experiments that can be performed to estimate r for a partic...
1. There are many simple experiments that can be performed to estimate r for a partic ular problem, and we encourage you to perform your own. The parts below discuss some experiments that we or our students have performed in the past. For each part, discuss conditions that are needed in order to sat...
1 answers
1 3. MgCO3co → Mg Ocss + CO2 caj a.) To prepare 70.0g start with how...
1 3. MgCO3co → Mg Ocss + CO2 caj a.) To prepare 70.0g start with how many of g Mgo you of Mg CO3 ? must b. How many as a by g of CO2 would product? be generated...
1 answers
9. A patient hands you a prescription for ipratropium bromide 0.5 mg/albuterol 2.5 mg solution for...
9. A patient hands you a prescription for ipratropium bromide 0.5 mg/albuterol 2.5 mg solution for nebulization. It is for one box of 60 vials and the patient is to use 1 vial q6 hrs. What day supply will you enter in the pharmacy computer system? (2 points)...
1 answers
Multiple Choice (2 points each) Circle the best answer to each of the following questions. 1....
Multiple Choice (2 points each) Circle the best answer to each of the following questions. 1. When a company has performed services for a client but has not yet received payment, it: a. makes no entry until the cash is received. b. debits Accounts Receivable and credits Revenue. debits Accounts Paya...
1 answers
Activity-Based Costing and Product Cost Distortion Digital Storage Concept Inc. is considering a change to activity-based...
Activity-Based Costing and Product Cost Distortion Digital Storage Concept Inc. is considering a change to activity-based product costing. The company produces two products, cell phones and tablet PCs, in a single production department. The production department is estimated to require 4,000 direct ...
1 answers
Why do elements in the same group have a similar reactivity?
Why do elements in the same group have a similar reactivity?...
1 answers
QUESTION 1 (a) Apart from = 0 the equation f(t) = 12 - 4sin r =...
QUESTION 1 (a) Apart from = 0 the equation f(t) = 12 - 4sin r = 0 has another root in (1, 2.5). Perform three (10) iterations of the bisection method to approximate the root. State the accuracy of the root after the three iterations. (b) Perform three iterations of Newton's method for the functi...
1 answers
Find the general indefinite integral. 15. 14 1 - sint -dt sint Answer sin 2.c 16....
Find the general indefinite integral. 15. 14 1 - sint -dt sint Answer sin 2.c 16. dc sin 3...
1 answers
Your tire pressure gauge indicates that the pressure in your cold tires is 250 kPa on...
Your tire pressure gauge indicates that the pressure in your cold tires is 250 kPa on a mountain at an elevation of 3500 m. (a) What is the absolute pressure in your tires? (b) After your drive down to sea level, your tires have warmed to 25 C. What does your tire pressure gauge indicate now? assume...
1 answers
How do you solve #2A/3 = 8 + 4A#?
How do you solve #2A/3 = 8 + 4A#?...
1 answers
John was studying how far the UMN students travelled to take the class orn campus. Let...
John was studying how far the UMN students travelled to take the class orn campus. Let W be the distance travelled (measured in miles). A sample of size 25 was collected. He calculated the following statistics: W -3.8 Calculate the sample variance. Please round the answer to the nearest hundredth....
1 answers
A uniform magnetic field is perpendicular to the plane of a circular loop of diameter 14...
A uniform magnetic field is perpendicular to the plane of a circular loop of diameter 14 cm formed from wire of diameter 2.0 mm and resistivity of 2.16 x 10 p-m. At what rate must the magnitude of the magnetic fleld change to induce a 13 A current in the loop? Number Units the tolerance is +/-7%...
1 answers
The 2kg arm AB is connected to the 5kg trolley by a frictionless pivot as shown below. The length of AB is 1.5m and it...
The 2kg arm AB is connected to the 5kg trolley by a frictionless pivot as shown below. The length of AB is 1.5m and it can be assumed to be a slender rod. 100N The system is initially stationary before the 100N force is applied at B. (a) Draw a free body diagram of both the trolley and arm. [2 marks...

-- 0.048990--