- Which of the following function declarations is correct?
int computeAvg(int[][] grades, int rowSize, int columnSize);
int computeAvg(int grades[3][], int rowSize);
int computeAvg(int grades[][3], int rowSize);
int computeAvg(int grades[][], int rowSize, int columnSize);
- Which of the following is true for dynamically allocated arrays in C++? (select all that apply)
Every element in an array has the same base type.
The array will grow dynamically to accommodate additional elements.
The array elements are always initialized to 0 when an array is created.
Array size must be declared by a constant expression
It is always a fatal error to access outside of the array bounds.
The array must be explicitly deleted when the programmer is done with it.
Which of the following will compile correctly? (select all that are correct)
int coeffs(2);
int coeffs = new int[2];
int *coeffs = new int(2);
int coeffs[];
int **coeffs = new int*[2];
Step by stepSolved in 2 steps
- Jupyter Notebook Fixed Income - Certicificate of Deposit (CD) - Compound Interest Schedule An interest-at-maturity CD earns interest at a compounding frequency, and pays principal plus all earned interest at maturity. Write a function, called CompoundInterestSchedule, that creates and returns a pandas DataFrame, where each row has: time (in years, an integer starting at 1), starting balance, interest earned, and ending balance, for an investment earning compoundedinterest. Use a for(or while) loop to create this table. The equation for theith year's ending balance is given by: Ei =Bi (1+r/f)f where: Ei is year i's ending balance Bi is year i's beginning balance (note: B1 is the amount of the initial investment (principal) r is the annual rate of interest (in decimal, e.g., 5% is .05) f is the number of times the interest rate compounds (times per year) The interest earned for a given year is Ei - Bi Note the term of the investment (in years) is not in the above equation; it is used…arrow_forwardWrite a c++ function that accepts an array of doubles and the array’s size as its only arguments. The function should use dynamic memory allocation to create a new array that is double the size of the argument array. The function should copy the contents of the argument array to the second half of the new array and initialize the first half of the new 0s. The function should return a pointer to the new array. So, if the original array contained 1 2 3 4, the new array should contain 0 0 0 0 1 2 3 4. So, if the original array contained 1 2 3 4, the new array should contain 0 0 0 0 1 2 3 4.arrow_forwardWRITE A PROGRAM IN C++ You work for an loan analytics organization have been tasked with writing a program that simulates an analysis of loan applications. Code a modular program that uses parallel arrays to store loan application credit scores (values generated between 300 and 900), score ratings (poor, fair, good, very good, or exceptional based on credit score) and loan status (approved or declined applications based on credit score). The program must do the following: The program must first ask the user for the number of loan applications that will be in the simulation. This must be done by calling the getNumLoanApplications() function (definition below). After the input of the number of accounts, the program must use loops and random numbers to generate the credit score, score rating, and application result for each loan application in parallel arrays. These arrays must not be declared globally (major error). The following arrays must be declared and populated: creditScores[]…arrow_forward
- IN C PROGRAMMING LANGUAGE: Please write a pointer version of squeeze() named psqueeze(char *s, char c) which removes c from the string s.arrow_forwardIs there any way I can get rid of these warnings below? c: In function 'sortProducts': c:165: warning: assignment makes integer from pointer without a cast c:167: warning: assignment makes integer from pointer without a cast c:178: warning: assignment makes integer from pointer without a cast c: In function 'palindrome': c:211: warning: assignment makes integer from pointer without a cast c:211: warning: 'i' is used uninitialized in this function c: In function 'sortProducts': c:165: warning: 'i' is used uninitialized in this function Here is the program below. 157 int * sortProducts (int* A) 158 { 159 //LOCAL DECLARATIONS 160 int t; //temporary variable t 161 int *j; //dkdsk 162 int *i; //smkl mkl 163 164 //EXECUTABLE STATEMENTS 165 for (*i = A; *i != -1; i++) 166 { 167 for(*j = (i + 1); *j != -1 ; j++) 168 { 169 if(* (i) > * (j)) 170 { 171 t = * (i); 172 *i = * (j); 173 * (j) = t; 174 } 175 } 176 } 177…arrow_forwardChoose if each of the following is true or false:Dynamically binding data to virtual functions is limited to pointers and references.arrow_forward
- Write a function named rockPaperScissors. It should have one input:- An array with 2 elements, each representing a player in the game of Rock Paper Scissors.It should return one output- A scalar with the result of the game.For the purposes of this program, assume the following numerical code:- 1 is rock- 2 is paper- 3 is scissorsIn the game of Rock, Paper, Scissors, rock beats scissors, paper beats rock, and scissors bears paper. Ifplayers play the same object, the result is a tie.Your output should be:- The index of the winning player if there is a winner.- 0 if there is a tie- -1 if a player played an invalid object (a number that is not 1, 2, or 3)For example, if we called our function:result = rockPaperScissors([1 2]);result would be 2, as paper beats rock.If we called our functionresult = rockPaperScissors([3 2]);result would be 1 because scissors beats papearrow_forwardComplete this code using Python m1 = [] #Matrix 1m2 = [] #Matrix 2#Write a function that will return the addition of Matrix A and B.#Create a new matrix C that will hold the addtion result of Matrix A and B (A+B).#Return the resultant matrix Cdef addMatrix(A,B):#Write your code here#Write a function that will return the subtraction of Matrix B from A.#Create a new matrix C that will hold the substraction result of Matrix B from A (A-B).#Return the resultant matrix Cdef subsMatrix(A,B):#Write your code here#Write a function that will return the multiplication of Matrix A and B.#Create a new matrix C that will hold the multiplication result of Matrix A and B (A*B).#Keep in mind,in order to perform matrix multiplication, the number of columns in Matrix A must be equal to the number of columns in Matrix B. #Return the resultant matrix Cdef multipyMatrix(A,B):#Write your code here#Write a function that will transform matrix A to the transpose of matrix A.#The transpose of a matrix means…arrow_forwardWrite the following function #input: a numerical vector x #output:the normalized vector, i.e. the vector rescaled into [0,1] # the formula to normalize is (x-min(x))/ (max(x)-min(x)) # you can NOT use the functions min and max # you can use %%, nrow, ncol, and length # you can write multiple functionsarrow_forward
- Create a function that accepts an array of pointers as an argumentCreate one function that contains only one for loop to print the passed array of pointer.So, lines from //A to //B need to be replaced with only two function calls: one function call to printmonths (from the month array), and the second function call for printing the days (form the dayarray). Both function calls are for the same function but with different parameters.arrow_forwardIt’s due in C++ Please tell me which code is for StudentMaim.c and which for studentInfo.h and studentInfo.carrow_forwardGive an example of a function with two arguments and statements that are executed when the function is called. -Provide details about the return statement and the purpose of your function. -Provide an example of an array and a vector. -Describe your experience using GitHub, GitLab, Git, or other versional control software in general. Explain what aspects of the GitHub process you are comfortable with and what areas you need more practice or help.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education