Question: #include void modifyArray(int b[], int size); void modifyElement(int e); int calculateSum(int n[]); int main(void) { int n[5] = {32, 27, 64, 18, 95}; int i,

#include  void modifyArray(int b[], int size); void modifyElement(int e); int calculateSum(int n[]); int main(void) { int n[5] = {32, 27, 64, 18, 95}; int i, result; int total = 0; printf("Element Value "); for (i = 0; i < 5; ++i) { printf("%7u%13d ", i, n[i]); total += n[i]; } result = calculateSum(n); printf("Total array elements values is %d ", total); printf("Result array elements values is %d ", result); modifyArray(n, 5); for (i = 0; i < 5; ++i) { printf("%7u%13d ", i, n[i]); total += n[i]; } printf("Total array elements values is %d ", total); result = calculateSum(n); printf("Result array elements values is %d ", result); modifyElement(n[3]); for (i = 0; i < 5; ++i) { printf("%7u%13d ", i, n[i]); total += n[i]; } printf("Total array elements values is %d ", total); result = calculateSum(n); printf("Result array elements values is %d ", result); } int calculateSum(int n[]) { int sum = 0; int i; for(i = 0; i < 5; i++) { sum += n[i]; } return sum; } void modifyArray(int b[], int size) { int j; for ( j = 0; j < size; ++j) { b[j] *= 2; } } void modifyElement(int e) { printf("Value in modifyElement is %d ", e *= 2); } 

  1. Open your Linux Shell, compile it and run. What is the output you obtained?

  1. Explain what main function is doing?

  1. How many functions main function is calling? Name them.

  1. Explain what is the purpose of void modifyArray(int b[], int size);

  1. Explain what is the purpose of void modifyElement(int ;

  1. Explain what is the purpose of int calculateSum(int n[]);

  1. Explain why total and result give different values in some of the print outs. Try inserting a printf("Total value is: %d ", total); inside the for loops, just before the array print out. This will help you to determine what is the value of total inside these for loops.

  1. Explain why the value in from the modifyElement is 72 and the print out for this array does not shows this change of value?

  1. Now, go to the first FOR loop inside the MAIN function, and change its parameters to: for (i = 0; i < 7; ++. Compile the program and run it. Copy you output and Explain the results.

  1. Explain what happened to the Result variable and why:

  1. Return this FOR loop to its original parameters for (i = 0; i < 5; ++i).

  1. Remove the number of elements from the n[] array declaration (delete the number 5): int n[ ] = {32, 27, 64, 18, 95};. Compile the program and run it. What happens to your output and why.

  1. Now, declare the array to be of 4 elements, but initialize five, like this: int n[4] = {32, 27, 64, 18, 95};. Compile the program and run it. What happens to your output and why.
  2. Now, declare the array to be of 5 elements, but initialize 4 (delete the last value), like this: int n[5] = {32, 27, 64, 18 };. Compile the program and run it. What happens to your output and why.

please help

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 Databases Questions!