1.
If the below function countAll is called like this:
countAll(10, 15);
There will be an infinite loop. How would you fix this problem?
void countAll(int num, int end)
{
cout << num << " ";
countAll(num + 2, end);
}
Group of answer choices
A.Change the 'cout' to print 'end' instead of 'num'
B.Make the function return a string
C. Change 'num + 2' to 'num + 1'
D.It is not possible to fix
E. Add a base case where countAll() is not called again
2.
If you attempt to store data past an array's boundaries, you will always get a compiler error.
Group of answer choices
A.True
B.False
3.
To make this code output 31, which line is correct?
int number = 31; int *var = &number;
Group of answer choices
A. cout << &number << endl;
B. cout << &var << endl;
C.cout << *var << endl;
D.cout << "var" << endl;
E. cout << var << endl;
4.
In the below array declaration, there is no size given. What else must be provided?
int array[];
Group of answer choices
A.nothing; this will compile
B.a blank line immediately after the array definition
C.the word 'automatic' before the array
D.an initialization list such as 'int array[] = { 10, 12 };'
5.
Which of the below are valid C++ array definitions? (Select all that apply).
Group of answer choices
A.double sigfigs[10.1];
B.void numbers[5];
C. float $payments[10];
D.int nums[0];
E. int sizes[10];
1.
E. Add a base case where countAll() is not called again
2.
False
3.
C.cout << *var << endl;
4.
D.an initialization list such as 'int array[] = { 10, 12 };'
5.
D.int nums[0];
E. int sizes[10];
1. If the below function countAll is called like this: countAll(10, 15); There will be an...
using C++ only. The findFirstZero function is supposed to find the first element in an array whose value is zero, and sets the parameter p to point to that element, so the caller can know the location of that element holding the value zero. Explain why this function won't do that, and show how to fix it. Your fix must be to the function only; you must not change the main routine below in any way. As a result of your fixing...
1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates a vector object that can only store values of 10 or less. B.It creates a vector object with a starting size of 10. C.It creates a vector object and initializes the first element with the value 20. D.It creates a vector object with a starting size of 20. 2. A recursive function contains a call to itself, but is limited to 10 recursive calls...
REWRITE the code below and declare a class that holds an array of 10. Create a constructor that initializes the array with random integers 1 and 100. Write a member function to show the entire array and another to sort the array. Rewrite with instruction above: //Exchange Sort Function for Descending Order void ExchangeSort(vector<int> &num) { int i, j; int temp; // holding variable int numLength = num.size(); for (i=0; i< (numLength -1); i++) {...
Language is C++ Complete the following Review Questions: 1. This is a control structure that repeats a group of statements in a program? a. loop b. switch c. main() function d. compiler 2. In the expression number++,the ++operator is in what mode? a. Prefix b. Pretest c. Postfix d. Posttest 3.This is a variable that controls the number of iterations performed by a loop. a. Loop control variable b. Accumulator c. Iteration register variable d. Repetition meter 4. The do-whileloop...
C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...
In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle : - radius (input argument) - area (output argument, to be calculated) - circumference (output argument, to be calculated) All arguments are double type. If a radius is negative, the function returns false, otherwise it returns true. The function does only calculation, and does nothing else. Assume that all #include are already there // Fill in your Function prototype bool circleAreaAndCircumference ( _______,...
How can I write this code (posted below) using vectors instead of arrays? This is the task I have and the code below is for Task 1.3: Generate twenty random permutations of the number 0, 1, 2, ..., 9 using of the algorithms you designed for Task 1.3. Store these permutations into a vector and print them to the screen with the additional information of unchanged positions and number of calls torand(). Calculate the total numbers of unchanged positions. Compare...
C++ Create a function called countOccurences that will count how many times a certain number occurs in the array. The function should take an array, a size and a variable, which is what you are searching for. Heres what I got so far: #include <iostream> #include <string> #include <vector> using namespace std; void fillArray(int a[], int size); void printArray(int a[], int size); int countEvens(int ar[], int size); int main() { int ar[10]; fillArray(ar, 10); printArray(ar, 10); ...
1. Implement a tostring() member function. This function will return a string representation of the LargeInteger. You should probably used string streams to implement this function. Note that the digits of the large integer are stored in reverse of their display order, e.g. the 1's place (100 ) is in index 0 of digits, the 10's place (101 ) is in index 1, etc. 2. Implement a second constructor for the LargeInteger. This constructor will be used to construct a...
c++, we have to write functions for the code given below and other
instructions for it to compile. I am having issues understanding
how to confront the problem and how to write functions and read the
program so it can eventually be solved so it can be compiled
7/ * INSTRUCTIONS: Write two functions in the space // * indicated below. // * // * #1 => Find index of maximum value: Write a function that will // * find...