Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
3rd Edition
ISBN: 9780134123837
Author: Randal E. Bryant, David R. O'Hallaron
Publisher: PEARSON
Question
Book Icon
Chapter 6, Problem 6.37HW
Program Plan Intro

Given Information:

Three different functions are given:

// declare 2-D array

typedef int array_t[N][N];

// function to add values of 2-D array

int sumA(array_t a) {

// variable declaration

int i, j;

int sum = 0;

// traverse through rows

for (i = 0; i < N; i++)

// traverse through elements

for (j = 0; j < N; j++) {

// sum of elements

sum = sum + a[i][j];

}

// return sum

return sum;

}

// function to add values of 2-D array

int sumB(array_t a) {

// variable declaration

int i, j;

int sum = 0;

// traverse through columns

for (j = 0; j < N; j++)

// traverse through rows

for (i = 0; i < N; i++) {

// sum of elements

sum = sum + a[i][j];

}

// return sum

return sum;

}

// function to add values of 2-D array

int sumC(array_t a)

{

//variable declaration

int i,j;

int sum=0;

//traverse through columns

for(j=0;j<N;j+=2)

//traverse through rows

for(i=0;i<N;i+=2)

{

//sum of elements

sum+=(a[i][j]+a[i+1][j]+ a[i][j+1]+a[i+1][j+1]);

}

//return sum

return sum;

}

Blurred answer
Students have asked these similar questions
Homework You have the row vector (A) that has values from (-100 to 100), write MATLAB codes to: (1) Interchange the first 10 elements with last ten elements. (2) Replace the elements at indices (93,9,17,50) of A with 99. (3) Return the second element and the element before the last of A as a column vector (C1). (4) Extract the first five elements and the last five elements of A and append them as a row vector (R). (5) Set the elements of A with odd indices to zeros(0).
if the error in a closed-loop Servo motor system is zero, why does the motor Contimac ranning instead of stopping
When the FCC added Color Television to the Industry Standards, they went with the system developed in the 1940s by Peter Goldman for CBS.   Question 15 options:   True   False Part of the reason that many critics disliked 1950s gameshows was the fact that gameshows offered one of the few opportunities to see unscripted interactions with "real" (average/non-famous) people on television.   Question 16 options:   True   False The Andy Griffith Show is an example of the "rural revival" shows that become enormously popular on 1960s American television.   Question 19 options:   True   False During the Network Era, the hours before primetime each day were exclusively devoted to locally-produced programming, not programming dictated by an affiliate station's parent network.   Question 20 options:   True   False
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
A+ Guide to Hardware (Standalone Book) (MindTap C...
Computer Science
ISBN:9781305266452
Author:Jean Andrews
Publisher:Cengage Learning
Text book image
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning