Question
I need some help. Trying to study. (10 Pts) Given the function definition below, what will the following code display? int num1 = 0, num2=1654893;
I need some help. Trying to study.
(10 Pts) Given the function definition below, what will the following code display? int num1 = 0, num2=1654893; cout << num1 << << num2 << endl; num1 = getLast(num2); cout << num1 << << num2 << endl; // program continues int getLast(int num2) { num2%=10; return num2; }
0 1654893 1 1654893 |
Syntax error. The function is trying to return num2 and put it into num1!
|
0 1654893 3 1654893 |
0 1654893 1654893 1654893 |
Flag this Question
Question 225 pts
(25Pts)Pick the best answer to accomplish the following task:
Write a function to accept a vector of ints and an int value, n. The function should double the value at location n in the vector, and then triple every value from n+1 to the end. There was code in main to ensure that n is less than the size of the vector.
void fixem(vector V[n]*=2; for(int i=0,i |
void fixem(vector V[n]*=2; for(int i=n+1,i |
void fixem(vector V[n]*=2; for(int i=n+1,i |
void fixem(vector V[n]*=2; for(int i=n+1,i |
Flag this Question
Question 320 pts
(20 Pts) Given this struct struct quizzes { int Q1; int Q2; int Q3; double Average; }; Choose the best answer to accomplish this task:write a function which accepts a vector of structs and puts the average of the three quizzes in the Average field for each struct in the vector.
void averageQuiz(vector |
void averageQuiz(vector |
void averageQuiz(vector |
void averageQuiz(vector |
Flag this Question
Question 420 pts
( 20 Pts) Select the best answer below:
Write a function which accepts a vector of strings and returns the average of the lengths of the strings.
double averageLength(const vector |
double averageLength(const vector |
double averageLength(const vector |
double averageLength(const vector |
Flag this Question
Question 510 pts
(10 Pts) The fastest search algorithm for vectors with a size greater than 50 is:
Linear Search
|
Linear Search with early exit |
Binary Search |
Shell Search
|
Quick Search |
Flag this Question
Question 625 pts
(25 Pts)Choose the best answer:
Write a function to accept a vector of strings and a char and return a count of how many times the char appears in the vector
int countChar(const vector |
void countChar(const vector |
int countChar(const vector |
int countChar(const vector |
Flag this Question
Question 720 pts
(20 Pts) Choose the best solution (Analyze ALL the possible answers before choosing):
Write a bool function, areSame, to accept two vectors of ints and return true if the two vectors contain the same values in every cell. . The vectors are the same size. Efficiency counts!
bool areSame(const vector |
bool areSame(const vector |
bool areSame(const vector |
bool areSame(const vector |
Flag this Question
Question 825 pts
(25 Pts)Choose the best answer:
Write a function to accept a vector of ints and an empty vector of bools. For each value in the vector of ints which is even, it should set the corresponding cell in the vector of bools to true. All others should be false.
void AreOK(vector else V2.push_back(true); } } |
void AreOK(const vector else V2=true; } } |
void AreOK(const vector else V2[i]=true; } } |
void AreOK(const vector else V2.push_back(true); } } |
Flag this Question
Question 920 pts
(20 Pts) Select the best solution:
Write a function that will accept an empty vector of ints and an int and will fill the vector with the ulam sequence beginning with the int. You may assume that the int is greater than 2.
vector int start) cout << "Enter starting number" << endl; cin >> start; V.push_back(start); while(start > 1) { if(start %2 ==0) start /=2; else start = start * 3 + 1; V.push_back(start); |
void ulam(vector { V.push_back(start); while(start > 1) { if(start %2 ==0) start /=2; else start = start * 3 + 1; V.push_back(start); } } |
void ulam(vector { for (i=start;i>1;i+=(i%2) { if(start %2 ==0) i /=2; else i = start * 3 + 1; V.push_back(i); } } |
void ulam(vector { V.push_back(start); while(start > 1) { if(start %2 ==1) start /=2; else start = start * 3 + 1; V.push_back(start); } } |
Flag this Question
Question 1020 pts
(20 Pts) What will be the value of V[2] after this code runs?
vector
3 |
6 |
0 |
That cell will be empty. |
Flag this Question
Question 115 pts
(5 Pts) Choose the correct function below:
void goodbye() { cout << "I hope you enjoyed the class!" << endl; }
|
This is the wrong answer! |
So is this! |
No answer text provided. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started