Write a C++ function that takes a two-dimensional array and a row index. The function should return the multiplication of all the values in the row. Write a main () program to test the function.
Student Note: Please solve the question as simple as you can.
#include <iostream>
using namespace std;
// change dimensions of matrix as you like here
#define NUM_ROWS 3
#define NUM_COLS 3
int multiply_rows(int matrix[][NUM_COLS], int row) {
int result = 1;
for (int i = 0; i < NUM_COLS; ++i) {
result *= matrix[row][i];
}
return result;
}
int main() {
int matrix[NUM_ROWS][NUM_COLS];
cout << "Enter matrix of " << NUM_ROWS << " rows and " << NUM_COLS << " columns" << endl;
for (int i = 0; i < NUM_ROWS; ++i) {
for (int j = 0; j < NUM_COLS; ++j) {
cin >> matrix[i][j];
}
}
int index;
cout << "Enter a valid row value from 0 to " << NUM_ROWS - 1 << ": ";
cin >> index;
cout << "Product of all numbers in row " << index << " is " << multiply_rows(matrix, index) << endl;
return 0;
}
Write a C++ function that takes a two-dimensional array and a row index. The function should...
Write a C++ program using function that takes a Two Dimensional array, number of rows and number of columns in that array as argument, and returns another 2D-array containing binary representation of those numbers.
Write a C++ function that takes a pointer to an array of integers as a parameter and return the number of prime integers in the array. Write main() program to test the function.
Please use C !!!
Write a C function matrixTranspose that takes a two-dimensional
array as its input argument then transposes its elements and prints
the results.
Develop the matrixTranspose method with two different
methods:
1. Assume the matrix is a square matrix. This will make finding the
transpose a simple swapping of the arrays’ elements and it can be
done in place.
2. Generalize your function to work with any NxM matrix where N≠M.
You will need to properly handle...
Write a C++ function, smallestIndex, that takes as parameters an
int array and its size and returns the index of the first
occurrence of the smallest element in the array. To test your
function, write a main that prompts a user for a list of 15
integers and outputs the index and value of the first occurrence of
the smallest value.
The program should print out
Enter 15 integers:
The position of the first occurrence of the smallest element in...
Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...
Write a program that deletes an element of a one-dimensional array of characters. The program should: Ask user to input the number of characters in the array the values of the array a character to be deleted Call a method to delete the character Print the resulting array or, if the character is not found, print “Value not found” The method called by the main program should: Pass the array and the character to be found as parameters If the...
Write a program that performs the following operations on a one dimensional array with 50 unsigned integers. The main program will initialize the array, print the array values to the screen and then call a function that will determine and print the maximum and minimum values. •Declare the array and any other variables. •Use a loop to initialize the array with 50 random integer values between 0 and 99 using the rand() function. (number = rand() % 100;) •Using cout...
Write a C++ program to scale and average the values in a two-dimensional array. Write the following functions: void randomize2DArray(int arr[ROW_SIZE][COL_SIZE]) – places random values between 1 and 100 in a two-dimensional array . void scale2DArray(int arr[ROW_SIZE][COL_SIZE], double scale) – multiplies every value in the two-dimensional array by scale. double average2DArray(int arr[ROW_SIZE][COL_SIZE]) – calculates the average value over all elements in the two-dimensional array. Randomize and print the values in the two-dimensional array of size 7 x...
Write a C program (not C++) that calls a function to multiply a matrix (two dimensional array). The main program should ask the user to enter an integer that will be used as the matrix “adder” and then call the function. The function should perform a matrix increment (every element of the array is incremented by the same value) and assign the result to another array. The function should be flexible enough to work with any array size and “adder”,...
Please solve only if you know how to do it. Write the code using
C++ (not Python or Java). Show and explain everything neatly.
COMMENTS (7.5% of programming assignment grade): Your program should have at least ten (10) different detailed comments explaining the different parts of your program. Each individual comment should be, at a minimum, a sentence explaining a particular part of your code. You should make each comment as detailed as necessary to fully explain your code. You...