Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please complete in C language #include stdio.h #include stdlib.h int main(int argc, char* argv[]) { int i, j, k; int count = 0; float arr2D[3][6];
Please complete in C language
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
int i, j, k;
int count = 0;
float arr2D[3][6];
float arr3D[4][5][6];
// populate the array arr2D
//
for (i = 0; i
for (j = 0; j
arr2D[i][j] = count;
count++;
}
}
// populate the array arr3D
//
count = 0;
for (i = 0; i
for (j = 0; j
for (k = 0; k
arr3D[i][j][k] = count;
count++;
}
}
}
// call the function to comute the sum arr2D[2]
// print the sum of arr3D[2]
return 0;
}
To do Code a function computeSum() that computes the sum of arr2D. Here function needs to traverse the array one element at a time. Note that the important aspect here is the declaration of the function. 2.1 how should the function be declared (what are the parameters)? Note, that you have to pass to the function a 2D array. Which dimension of the array do you have to specify? Do you have to provide any other parameter? Prototype int computeSum(float arr[][6]); or int computeSum(float arr[3][6]); Note that the latter one does not provide the compiler with more information than the first one. The importance of the declaration here is to provide the compiler with enough knowledge on how to progress when manipulating the sub-arrays. For example, the statement arr[2][O] = 2.1; requires the system with information on the second dimension in order to compute the memory location of arr[2][0]. The other parameter that must be specified is the size of the first dimension. Namely, how many "groupings" of 6 float are passed to the function. Therefore the function prototype should be int computeSum(float arr[][6], int sizep1); input: arr the 2D array sizeD1 - the size of the first dimensionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started