Write a function that sums all the numbers of the major diagonal in an nxn matrix of integers using the following header:def sumMajorDiagonal(m):The major diagonal is the diagonal that runs from the top left corner to the bottom right corner in the square matrix. Write a test program that reads a 4x4 matrix and displays the sum of all its elements on the major diagonal.
Q: Store N integers in an array and use the above function to compute the summation of the integers…
A: C program
Q: Q2) Write a program to take 10 integer inputs from user and store them in an array. Then, create a…
A: #include <iostream>using namespace std; int main(){ // declaring variables int…
Q: Write a function called hw3_problem1 that takes a matrix A of positive integers as its sole input.…
A: ANSWER:-
Q: Suppose you are given a 6 * 6 matrix filled with 0 and 1. All rows and all columns have the even…
A: Program: Programs are used to perform certain tasks according to the requirements. The programmer…
Q: Write a function that receives three arguments (a string containing a single character, the number…
A: CODE:#include <bits/stdc++.h>using namespace std;void myfunction(string str,int rows,int…
Q: Write a program that uses a 3 3 3 array and randomly place each integer from 1 to 9 into the nine…
A: Required: rite a program that uses a 3 3 3 array and randomly places each integer from 1 to 9 into…
Q: B) If you have a matrix M[3][3] of integer numbers, write a program to read it and then generates an…
A: Code: Output:
Q: Write a code that will do a) Reads the elements of two matrices M1 and M2 with the size of two rows…
A: // adding matrix for (int i = 0; i < 2; i++) { for (int j = 0; j<3; j++) {…
Q: Write a function that returns the sum of all the elements in a specified column in a matrix using…
A: Code:
Q: Write a function matrix1n() that gets an integer number (n) as parameter and returns a NumPy ara The…
A: The following python code will input the value of integer n. The code will create the matrix as…
Q: Write a function that displays an n-by-n matrix using the following header: void printMatrix(int…
A: Code: #importing the packagefrom random import randint#function as neededdef printMatrix(n):…
Q: Write a program in C++ which takes two 4 x 4 matrices as input from the user and displays the…
A: The matrix is arranged in rows and columns called two-dimensional arrays which are accessed like (i,…
Q: Write a program to rotate a matrix of integer values given the number of rota- tions. For example,…
A: C++ Code: #include<iostream> using namespace std; int main() { int n; cout<<"Enter…
Q: Write a function named(difference), that accepts an integer one-dimensional array and its size,…
A: The programming methodology is given by: Including header files Difference function that takes 1d…
Q: matrix of 0s and 1s) Write a function that displays an n-by-n matrix using the following header:…
A: Code: from random import randintdef printMatrix(n): for x in range(n): for y in range(n):…
Q: Write a function named aidojo that takes a an integer parameter n and return a string array answer…
A: It is evident from the screenshot that the output is different (in terms of the string but follows…
Q: Write C a program that reads two matrices of integers. It then generates the sum, difference and…
A: C code: #include <stdio.h>#define ROW 6#define COL 6 //function prototypesvoid add(int…
Q: Write a function matrix1n() that gets an integer number (n) as parameter and returns a NumPy array.…
A: Answer is given below .
Q: Write a program that uses a 3 x 3 array and randomly place each integer from 1 to 9 into the nine…
A: Since no programming language is mentioned, I am using c++. Code: #include <iostream>using…
Q: Write a program in C++ which takes two 4 x 4 matrices as input from the user and displays the…
A: c++ program is as given below : // C++ Program to Make a Calculator #include<iostream> using…
Q: Can you please correct my code? The correct output is on the left, while my output is on the right.…
A: Answer: I have fixed the error by some changing your code. you can see in below
Q: Write a function named aidojo that takes a an integer parameter n and return a string array answer…
A: Your question uses the words AI Dojo AIDojo While your examples use Fizz Buzz FizzBuzz In the…
Q: Q.3 Write a c++ program that asks the user to enter two numbers (from 100 to 999) to create a matrix…
A: NOTE Below is the program for the given question. Hope you understand it well. If you have any…
Q: Write program to input elements values of array A(6), then print the matrix B that represent inverse…
A: Since programming language not specified, solving in C++ Algorithm Start Var A[6], B[6] for k=0 to…
Q: Write a code to find either the sum above or below the main diagonal of an n by n matrix MAT of…
A: Step 1: Prompt and accept the value of n from user. Step 2: Check whether the value of n is less…
Q: A program that asks for the components of 2 non-zero vectors A and B in 2. R3, and displays the…
A: Two vectors are said to be orthogonal or perpendicular to each other if their dot product is 0
Q: Implement the following function to sort the columns in a two-dimensional array. A new array is…
A: Code: #include<iostream>using namespace std;const int SIZE=3;void sortColumns(const double m[]…
Q: Write a function that returns the sum of all the elements in a specified column in a matrix using…
A:
Q: Apply your knowledge about arrays and functions and write a program, which takes a positive intege N…
A: ANSWER:-
Q: Write a program that randomly fills in Os and 1s into a 5-by-5 matrix, prints the matrix, and finds…
A: Program to randomly fill 0s and 1s in 5 x 5 matrix, print the matrix and find max row, max col.
Q: Q.3 Write a c++ program that asks the user to enter two numbers (from 100 to 999) to create a matrix…
A: C++ program to print matrix elements reversely
Q: Write a code segment to add two matrices A and B, and store the results in matrix C. C = A+B, that…
A: Dear Student, As only code segment is asked in question instead of whole program, I am just…
Q: Create a function that accepts a two dimensional array of integers and displays a) Row by row ( fix…
A: A required program is as follows, #include<stdio.h> #define r 3 #define c 4 /*Define a…
Q: Q1: Write a computer program in F90 to generate a matrix A(n) which contains a real numbers…
A: Algorithm: Declare a program Declare an array A(100) Initialize variables such as s and c to 0…
Q: You are given a matrix of 3 rows and 4 columns. (implemented as a two dimensional array of type…
A: Initialize the header files. Ask the user to enter the value of the array using the prompt. Call…
Q: Write a function called GradientCount that accepts as parameter a two-dimensional array called…
A: Note: As no langauge is mentioned, therefore answering the given question in python. # Import the…
Q: Create a function that takes the dimensions of two triangles (as arrays) and checks if the first…
A: Algorithm - Take Input from user. Now use the below logic - if(brick[0]+brick[1] <…
Q: B) If you have a matrix M[3][3] of integer numbers, write a program to read it and then generates an…
A: NOTE : As the question is not specific about the programing language to be used, I have used JAVA to…
Q: Write a function which will find the average of all elements of an array of integers. Pass an array…
A: Program: #include<iostream> using namespace std; // Function that return average of an…
Q: Create a function that takes the dimensions of two triangles (as arrays) and checks if the first…
A: Algorithm - Take Input from user. Now use the below logic - if(brick[0]+brick[1] <…
Q: 1) Write a function named maxDiff which returns the maximum difference between any two values in a…
A: Given:- 1) Write a function named maxDiff which returns the maximum difference between any two…
Q: Write a code to find either the sum above or below the main diagonal of an n by n matrix MAT of…
A: #include<iostream.h> #include< conio.h> #include<stdio.h> #include<math.h>…
Q: B) If you have a matrix M[3][3] of integer numbers, write a program to read it and then generates an…
A: Since no programming language is mentioned, I am using c++. Algorithm: Start Read a 3x3 matrix…
Q: Write a program to declare an integer array of 50 elements. Write a function getArray() to get…
A: Step 1:- Program Approach:- 1.Create the getArray() function to accept the input from the user and…
Q: Create a function that takes the dimensions of two triangles (as arrays) and checks if the first…
A: In this problem, we will design the code in the javascript. Algorithm - First, we will create a…
Q: Write a program to read five integers and store them in a single array, then use a function that you…
A: NOTE: As per our guidelines we are supposed to answer only one question So post the other question…
Q: Write a program for reading a square matrix (A) 10,10, then calculate and find the following: 1- the…
A: Since no programming language is mentioned, I am using c language. Algorithm: 1. Start 2. Read…
Q: Write a function that takes as input an array of (type float) 5 numbers and prints the position and…
A: Note: - As the programming language is not mentioned to write the program so I am using C++ to write…
Q: Write a Python program to check whether a nxn matrix is a magic square.The magic square is a set of…
A: Out of 27 statements given in the options two were unused in the program. These were magic = False…
Write a function that sums all the numbers of the major diagonal in an nxn matrix of integers using the following header:
def sumMajorDiagonal(m):
The major diagonal is the diagonal that runs from the top left corner to the bottom right corner in the square matrix. Write a test program that reads a 4x4 matrix and displays the sum of all its elements on the major diagonal.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- PYTHON!!! Write a function called number_matrix(r,c) that takes two parameters r and c and PRINTS ON THE SCREEN a matrix of numbers as follows: 1 2 3 4 5 .... 2 3 4 5 6 .... 3 4 5 6 7 .... . .. In this pattern, each row contains c numbers and there are r rows. For example, number_matrix(4,3) results in: 1 2 3 2 3 4 3 4 5 4 5 6 Note that you shouldn't be printing anything other than the required matrix of numbers. Even empty strings may invalidate your answer . """ def number_matrix(r,c):Q5. Write a program that reads from the user an integer matrix with 10x10, and then rotate that matrix 180° (UPSIDE DOWN) after that, calculate the sum and the average of the main diagonal. Print the matrix after the rotation and the values of the sum and the average of the main diagonal.Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal = . The right to left diagonal = . Their absolute difference is . Function description Complete the function in the editor below. diagonalDifference takes the following parameter: int arr[n][m]: an array of integers Return int: the absolute diagonal difference Input Format The first line contains a single integer, , the number of rows and columns in the square matrix .Each of the next lines describes a row, , and consists of space-separated integers . Constraints Output Format Return the absolute difference between the sums of the matrix's two diagonals as a single integer. Sample Input 3 11 2 4 4 5 6 10 8 -12 Sample Output 15 Explanation The primary diagonal is: 11 5 -12 Sum across the primary diagonal: 11 + 5 - 12 = 4 The secondary diagonal is: 4 5…
- Write a function called number_matrix(r,c) that takes two parameters r and c and PRINTS ON THE SCREEN a matrix of numbers as follows: 1 2 3 4 5 .... 2 3 4 5 6 .... 3 4 5 6 7 .... ... In this pattern, each row contains c numbers and there are r rows. For example, number_matrix(4,3) results in: 1 2 3 2 3 4 3 4 5 4 5 6Write a function is ordered that takes an integer array and its size as parameters and returns true if the array elements are ordered in nondecreasing order and returns false if not. For example, integers in {10,0,1,1,5,1009} are ordered in nondecreasing order. On the other hand, integers in {1, 2, 3, 8, 4, 19} are not since 8 > 4Write a function called hw3_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = hw3_problem1([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. You are not allowed to use loops.
- Write a program in C++ which takes two 4 x 4 matrices as input from the user and displays the matrices in tabular form. Then ask user to make a choice: 1. Press 1 for matrix addition 2. Press 2 for matrix subtraction 3. Press 3 for matrix multiplication 4. Press 4 for matrix transpose Use 2D arrays to save matrix values and use functions to perform addition, subtraction, multiplication and transpose.Write a function that prints a diagonal line using asterisk characters. Your function should accept one parameter that determines the number of rows defining the length of the diagonal line. This value will always be a positive integer greater than or equal to 1 (e.g. 1, 2, 3, …). use this Java: public static void printPattern( int num );Please send me answer with in 10 min!! I will you rate you good for sure!! Please solve all the 4 parts!! Write a class named Homework in IntelliJ that implements:(1) A function that performs dot product between two vectors a and b:public static double dotProduct(double[] a, double[] b)(2) A function that performs matrix multiplication between aMat and bMat and returns theresult in cMatpublic static void matMultiply(double[][] aMat, double[][] bMat, double[][] cMat)(3) A function that takes a line (String) as input and breaks it up into words that may beseparated by space, comma or tab:public static String[] getLineWords(String line)(4) A main function that tests all the above functions and prints out the results. Code written (has errors, but this is the structure/ method I'm going for) public class Homework { public static double dotProduct(double[] a, double[] b) { double result = 0; for (int i = 0; i < a.length; i++) { result += a[i] * b[i]; } return result; } public static…
- Write a menu-driven program to read and display a p¥q¥r matrix. Also, find the sum, transpose, and product of the two p*q*r matricesWrite a function named(difference), that accepts an integer one-dimensional array and its size, returns the difference between the largest element and the smallest element. e.g. the array is [1,7,13,22,15,6,4,3,2,9,21] the output is:21Write a program in C++ which takes two 4 x 4 matrices as input from the user and displaysthe matrices in tabular form. Then ask user to make a choice:1. Press 1 for matrix addition2. Press 2 for matrix subtraction3. Press 3 for matrix multiplication4. Press 4 for matrix transposeUse 2D arrays to save matrix values and use functions to perform addition, subtraction,multiplication and transpose. Refer below examples to understand the concept of matrixoperations.