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
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
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