Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 6, Problem 6.45HW
Program Plan Intro
Given Information:
The given code is:
//method to transpose matrix
void transpose(int *dst, int *src, int dim)
{
//variable declaration
int i,j;
//traverse through matrix
for(i=0;i<dim;i++)
for(j=0;j<dim;j++)
//transpose
dst[j*dim+i]=src[i*dim+j];
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ program that fills a 5 x 5 matrix of integers. The matrix must be a static matrix; its size must be fixed at compile-time. Display the contents of the matrix. Query the user for an integer. Pass the matrix and the integer to a bool function that searches for the first occurrence, and only the first occurrence, of the integer in thematrix. If the integer is found, the function returns true (and passes back the row and column coordinates of the first occurrence of the integer); if not, the function returns false. Main then displays whether the integer was found in the matrix and if so, the coordinates of the first occurrence. The use of a break to exit a loop or a function should be avoided.
My code does not find the location of the first occurrence and does not use a bool function. Can you please help me to find the error.
This is my code:
#include <iostream>
#include <random>
using namespace std;
int main()
{
int guess, array[5][5];
bool found = false;
for(int…
Write a C++ program that fills a 5 x 5 matrix of integers. The matrix must be a static matrix; its size must be fixed at compile-time. Display the contents of the matrix. Query the user for an integer. Pass the matrix and the integer to a bool function that searches for the first occurrence, and only the first occurrence, of the integer in thematrix. If the integer is found, the function returns true (and passes back the row and column coordinates of the first occurrence of the integer); if not, the function returns false.
in c++ languagee pleaseee
Chapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 6.1 - Prob. 6.1PPCh. 6.1 - Prob. 6.2PPCh. 6.1 - Prob. 6.3PPCh. 6.1 - Prob. 6.4PPCh. 6.1 - Prob. 6.5PPCh. 6.1 - Prob. 6.6PPCh. 6.2 - Prob. 6.7PPCh. 6.2 - Prob. 6.8PPCh. 6.4 - Prob. 6.9PPCh. 6.4 - Prob. 6.10PP
Ch. 6.4 - Prob. 6.11PPCh. 6.4 - Prob. 6.12PPCh. 6.4 - Prob. 6.13PPCh. 6.4 - Prob. 6.14PPCh. 6.4 - Prob. 6.15PPCh. 6.4 - Prob. 6.16PPCh. 6.5 - Prob. 6.17PPCh. 6.5 - Prob. 6.18PPCh. 6.5 - Prob. 6.19PPCh. 6.5 - Prob. 6.20PPCh. 6.6 - Prob. 6.21PPCh. 6 - Prob. 6.22HWCh. 6 - Prob. 6.23HWCh. 6 - Suppose that a 2 MB file consisting of 512-byte...Ch. 6 - The following table gives the parameters for a...Ch. 6 - The following table gives the parameters for a...Ch. 6 - Prob. 6.27HWCh. 6 - This problem concerns the cache in Practice...Ch. 6 - Suppose we have a system with the following...Ch. 6 - Suppose we have a system with following...Ch. 6 - Suppose that a program using the cache in Problem...Ch. 6 - Repeat Problem 6.31 for memory address0x16E8 A....Ch. 6 - Prob. 6.33HWCh. 6 - Prob. 6.34HWCh. 6 - Prob. 6.35HWCh. 6 - Prob. 6.36HWCh. 6 - Prob. 6.37HWCh. 6 - Prob. 6.38HWCh. 6 - Prob. 6.39HWCh. 6 - Given the assumptions in Problem 6.38, determine...Ch. 6 - You are writing a new 3D game that you hope will...Ch. 6 - Prob. 6.42HWCh. 6 - Prob. 6.43HWCh. 6 - Prob. 6.45HWCh. 6 - Prob. 6.46HW
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- in C language pleasearrow_forwardin c++ please Write a function called Replace All that cerpts two parameters a matrix of 100 elements of type inter and an interval y. The function must - Replace every positive matrix element by the values +5and Replace every negative matrix element by the value - 5 and - Replace every mero try the value y.arrow_forwardWrite a C program for Making a diagonal Matrix:A diagonal matrix is a square matrix in which all the elements that are NOT in the principal diagonal arezeros.Consider a 3*3 (row* col) matrix with the value follows,{1,2, 3}, {4,5, 6),{ 7, 8, 9}Your task is to make it a Diagonal matrix.Please crate two function - 1) printMatrix to print the entire Matrix. 2) makingDiagonal to transformthe matrix into diagonal. Check the image for sample output:arrow_forward
- Write a program in C++ that initializes a 4 x 4 Matrix as given below and then finds and displays the transpose of that matrix. matrix. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 6 10 14 3 7 11 15 4 8 12 16 5 9 13 17arrow_forwardWrite a procedure called STRUCTURE-TO-MATRIX that takes an adjacency structure as its only parameter, and returns an equivalent adjacency matrix. Assume there is a procedure MAKE-MATRIX(m, n) that returns an m × n integer matrix, where m ≥ 0 and n ≥ 0. The integers in this matrix are undefined.arrow_forwardComputer Science write a c++ code to read an adjancy matrix(B) size 6*6 from text file and compare the matrix from file to another matrix (a) note : just read one matrix from file and the other enter in code . detirmine if the two matrix (a) and (B) is isomorphic matrix a= 0 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 0arrow_forward
- Write a function max_matrix(M) that takes in a non-empty matrix (a 2-dimensional array) of real numbers M and returns its maximum value. You must use loops in your code. In pythonarrow_forwardIn c programming without pointer and function Problem Statement A matrix is a 2D array of numbers arranged in rows and columns. We give you a Matrix of N rows and M columns. Now your task is to do this operation on this matrix: If the value matches with the current row and column number then add 3 with the value. If the value matches with only the current row number then add 2 with the value. If the value matches with only the current column number then add 1 with the value. Input Format The first line contains N is the number of rows in this matrix and M is the number of columns in this matrix The second line contains a 2D array Arr[i][j]. Constraints 1 <= N, M <= 10 0 <= Arr[i][j] <= 100 Output Format Print the matrix after the operation is done. Sample Input 0 3 31 1 11 1 11 1 1 Sample Output 0 4 3 3 2 1 1 2 1 1arrow_forwardPROGRAMMING LANGUAGE: C++ Please test the code first before uploading here in bartleby. The expected outcome for each of the test case is also given in the screenshot. Follow accordingly. Thanksarrow_forward
- Can you write in c program?arrow_forwardJohn is playing a dice game. The rules are as follows. Roll two dice. Add the numbers on the dice together. Add the total to your overall score. Repeat this for three rounds. But if you roll DOUBLES, your score is instantly wiped to 0 and your game ends immediately! Create a function which takes in a matrix as input, and return John's score after his game has ended (10 points). Example: diceGame([[1, 2], [3, 4], [1, 1]])→ 10 WRITE IN PYTHON PLEASEarrow_forwardIn c langauge program. Please show the output of the program. thank youarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education