COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
3rd Edition
ISBN: 9780134671123
Author: Bryant
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
D. S. Malik, Data Structures Using C++, 2nd Edition, 2010
Methods (Ch6) - Review 1. (The MyRoot method) Below is a manual implementation of the Math.sqrt() method in Java. There are two methods, method #1 which calculates the square root for positive integers, and method #2, which calculates the square root of positive doubles (also works for integers). public class SquareRoot { public static void main(String[] args) { } // implement a loop of your choice here // Method that calculates the square root of integer variables public static double myRoot(int number) { double root; root=number/2; double root old; do { root old root; root (root_old+number/root_old)/2; } while (Math.abs(root_old-root)>1.8E-6); return root; } // Method that calculates the square root of double variables public static double myRoot(double number) { double root; root number/2; double root_old; do { root old root; root (root_old+number/root_old)/2; while (Math.abs (root_old-root)>1.0E-6); return root; } } Program-it-Yourself: In the main method, create a program that…
I would like to know the main features about the following 3 key concepts:1. Backup Domain Controller (BDC)2. Access Control List (ACL)3. Dynamic Memory
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