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

Some one please help me understand these. These are the wrong options I have, I

ID: 3712561 • Letter: S

Question

Some one please help me understand these. These are the wrong options I have, I need to know of the last two options which is right so I understand for later.

Q1) Options 1 and 2

Q2) Options 1 and 3

Q3) Options 1 and 2

Q4) Options 1 and 4

Q5) Options 2 and 4

Question 1 10 pts (10 pts)Select the best answer for the following task (Efficiency counts): Write code to declare a vector of type int, fill it with 360 random values in the range 1 to 250 inclusive, and then display the sum of the values in the vector. (Efficiency counts vector cint> V int size-360, sum-0; forlint i-0:iksize:it+) V.push, backrand()%250+1); sum+- Vil: No need for two loops! cout

Explanation / Answer

Question 1:
Answer is 3 because here we are specifying the size initially so when adding the elements vector dont need to increase the size, if we dont specify size than after adding few elements it will be resize and all existing elements will be copied
Question 2:
Answer 4:
Because option2 is syntax is incorrect we did't specify the method return type and parameters, in option 4 we specified everything correctly
Question 3:
Answer 4:
in option 3 we are filling the vector which is not required because already we are getting the vector with values

Question 4:
Answer is 2:
here in the option 2 we are using push_back to insert values into char array which is correct way but in option 3 we are using v2[] here V2 is not having any values right now
Question 5:
Answer 3:
we should use const to prevent vetor from modyfing

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