Question

#define SIZE 3 #define SIZE 5 MATRIX A MATRIX A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MATRIX A 0 0 0 0 0 0 0 0 0 0 1 1 1 MATRIX A 1 0 1 1 1 1 1 1 1 1 1 MATRIX B 1 0 0 0 1 1 0 0 0 1 2 2 2 1 0 0 0 1 2 0 2 1 1 1 1 1 2 2 2 MATRIX B 2 2 2 2 2 2 0 0 0 2 2 0 0 0 2 2 0 0 0 2 2 2 2 2 2

          #define SIZE 3
#define SIZE 5
MATRIX A
MATRIX A
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
MATRIX A
0
0
0
0
0
0
0
0
0
0
1
1
1
MATRIX A
1
0
1
1
1
1
1
1
1
1
1
MATRIX B
1
0
0
0
1
1
0
0
0
1
2
2
2
1
0
0
0
1
2
0
2
1
1
1
1
1
2
2
2
MATRIX B
2
2
2
2
2
2
0
0
0
2
2
0
0
0
2
2
0
0
0
2
2
2
2
2
2
        
Show more…
#define SIZE 3
#define SIZE 5
MATRIX A
MATRIX A
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
MATRIX A
0
0
0
0
0
0
0
0
0
0
1
1
1
MATRIX A
1
0
1
1
1
1
1
1
1
1
1
MATRIX B
1
0
0
0
1
1
0
0
0
1
2
2
2
1
0
0
0
1
2
0
2
1
1
1
1
1
2
2
2
MATRIX B
2
2
2
2
2
2
0
0
0
2
2
0
0
0
2
2
0
0
0
2
2
2
2
2
2

Added by Kimberly H.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
COMPUTER PROGRAMMING LAB APPLICATION 2: POINTER Define a matrix of size N x N. The number N will be specified with the #define preprocessor instruction and dynamic memory will not be used. In order to get points for the following items, your app should work fine for different N values as well and should not use nested loops. Using pointers: 1) Assign 0 to all elements of the matrix and print the output to the screen. (20p) 2) Update the elements on the edges of the matrix to be 1 and print the output to the screen. (50p) 3) Assign twice the elements in the matrix to another matrix and print the output to the screen. (30p) You can define two matrices and their pointers like this: int A[SIZE][SIZE], B[SIZE][SIZE]; int *p, *q; Example outputs for different sizes: #define SIZE 3 MATRIX A 0 0 0 0 0 0 0 0 0 MATRIX A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MATRIX A 0 0 0 0 0 0 0 0 0 MATRIX B 1 1 1 1 0 1 1 1 1 MATRIX B 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 MATRIX B 2 2 2 2 0 2 2 2 2 MATRIX B 0 1 2 2 2 2 2 0 0 0 0 2 0 2 2 0 2 2
Close icon
Play audio
Feedback
Powered by NumerAI
Jennifer Stoner David Collins
Danielle Fairburn verified

Supreeta N and 99 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
1-implement-a-simple-matrix-multiplication-program-in-c-or-c-matrix-multiplication-of-c-a-x-b-where-ab-and-c-are-matrices-of-size-n-x-n-n-rows-and-n-columns-and-both-a-and-b-are-initialised-32292

Implement a simple matrix multiplication program in C or C++. Matrix multiplication of C = A X B, where A, B, and C are matrices of size N x N (N rows and N columns) and both A and B are initialized with random values. At the end of the program, you should write your output to a file. How does matrix multiplication work? Please see here (https://en.wikipedia.org/wiki/Matrix_multiplication). To calculate C[i][j] (row i, column j), you multiply every element in matrix A row i by every element in matrix B column j. This requires three nested loops.

Supreeta N.

write-a-program-to-implement-fragments-using-array-of-pointers-c-languge-deseription-implement-fragments-using-array-of-pointers-rows-are-static-and-columns-are-dynamic-fixed-noof-rows-and-c-52907

Description: Implement fragments using an array of pointers. Rows are static and columns are dynamic. Fixed no.of rows and columns will vary for each row. Example: Read no.of rows from user and allocate the memory statically for rows. Read no.of columns for each row and allocate the memory dynamically. Let us Assume, Row = 3. Row[0] = 4 columns, Row[1] = 3 columns and Row[2] = 5 columns. While allocating the memory for columns you have allocate for no.of columns + 1 dynamically. After that read the values from user and calculate the average for each row seperatly and store that average in that extra memory block which you added while allocating the memory. Example is given below.Then sort the array based on the average. Print the output on the screen. Pictorial representation of the assignment Sample Execution: Test case 1: user@fragmentsEnter Enter no.of rows : 3 Enter no of columns in row[0] : 4 Enter no of columns in row[1] : 3 Enter no of columns in row[2] : 5 Enter 4 values for row[0] : 1 2 3 4 Enter 3 values for row[1] : 2 5 9 Enter 5 values for row[2] : 1 3 2 4 1 Before sorting output is: 1.000000 2.000000 3.000000 4.000000 2.500000 2.000000 5.000000 9.000000 5.333333 1.000000 3.000000 2.000000 4.000000 1.000000 2.200000 After sorting output is: 1.000000 3.000000 2.000000 4.000000 1.000000 2.200000 1.000000 2.000000 3.000000 4.000000 2.500000 2.000000 5.000000 9.000000 5.333333

Akash M.

in-c-please-design-a-class-to-perform-various-matrix-operations-a-matrix-is-a-set-of-numbers-arranged-in-rows-and-columns-therefore-every-element-of-a-matrix-has-a-row-position-and-a-column-10188

Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6 and sometimes denote it as A_{5 imes6}. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two matrices can be added and subtracted if they have the same size. Suppose A = [a_{ij}] and B = [b_{ij}] are two matrices of the size m X n, in which a_{ij} denotes the element of A in the ith row and the jth column, and so on. The sum and difference of A and B are given by: A + B = [a_{ij} + b_{ij}] A - B = [a_{ij} - b_{ij}] The multiplication of A and B (A * B) is defined only if the number of columns of A is the same as the number of rows of B. If A is of the size m X n and B is of the size n X t, then A * B = [c_{ik}] is of the size m X t and the element c_{ik} is given by the formula: c_{ik} = a_{i1}b_{1k} + a_{i2}b_{2k} + ... + a_{in}b_{nk} Design and implement a class matrixType that can store a matrix of any size. Overload the operators +, -, and * to perform the addition, subtraction, and multiplication operations, respectively, and overload the operator << to output a matrix. Also, write a test program to test various operations on the matrices.

Supreeta N.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,355 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,697 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,719 solutions

*

Transcript

-
00:01 Student a simple matrix program in c+ + that generate random matrix a and b of size n into n multiply them and write the result matrix c to the output file.
00:10 So here random values are taken into the matrices a and b.
00:15 So here i have taken the capital n its type is integer and it's a constant and its value i have initialized to 3.
00:22 We can take any value.
00:23 So here i have taken the function void type generate random matrix because here the matrix having the random number.
00:30 So i am taking as argument matrix 2d matrix n by n.
00:35 So here i am taking the 2 follows because of one for the row and second one for the column.
00:39 And here after this generate random number between 0 and 9.
00:44 So in 2d matrix we will call the we will fill the number by the rand function.
00:50 This will generate the random number between 0 and 9 0 up to 9.
00:54 So in this way we will fill the matrix matrix entries and now call the function multiply matrix.
01:03 So here its type is also void here i am using a 3 for loop int i equal to 0 int j equal to 0 and after this cij initialized to 0 and after this i have taken the third loop k equal to 0 as we know very well matrix multiplication is done with the help of a 3 loop.
01:23 So cij will be the new matrix and its value will be filled by multiplying aij.
01:30 So here cij plus aik into bkj.
01:34 So here rows of the first will be multiplied by the column of the second.
01:39 So in this way matrix multiplication will be performed as we know very well to perform the matrix multiplication.
01:47 So here first matrix and here second matrix.
01:53 So here suppose it's a it's b.
01:55 So here rows will be multiplied by the column of this one and here the result will be saved into the matrix c.
02:04 So in this way the matrix multiplication take place.
02:08 So here i have done with the help of a 3 loop.
02:10 So this will calculate the values of cij and all the entries of cij will be filled.
02:16 Now i am calling the main function in the main function seed the random number generator...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever