Question: Provide an improved C implementation of the code that is provided. Build, run and test your program. (no global variable)(code in C language only) code

Provide an improved C implementation of the code that is provided. Build, run and test your program. (no global variable)(code in C language only)

code :

#include const int size = 10;

void setArray(int A[], int size){ for (int i =0; i < size; i++) { A[i] = i; } }

void sumArray(int B[], int size, int *sum) { for (int i =0; i < size; i++) { *sum += B[i]; } }

void printArray(int C[], int sum, int size){ for (int i =0; i < size; i++) { printf("%d ", C[i] ); }

printf(" ");

printf("sum is %d ", sum); }

int main() { const int size = 10; int B[size], sum = 0; setArray(B, size);

sumArray(B, size);

printArray(B, sum, size);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!