Question: Could you do that in C language? I need to do programming with Recursion and Recursive Functions Here is the code we got #include int

 Could you do that in C language? I need to doprogramming with Recursion and Recursive Functions Here is the code we got

Could you do that in C language?

I need to do programming with Recursion and Recursive Functions

Here is the code we got

#include  int fillTheArrayFromFile(char fileName[], int array[]); int sum(int array[], int startIndex, int endIndex); int main(void) { char fileName[100]; printf("Please enter the file name: "); gets(fileName); int array[20]; int arraySize = fillTheArrayFromFile(fileName, array); if (arraySize == -1) { // checking the error condition printf("Error in reading the file. "); return 1; } int result; result = sum(array, 0, arraySize - 1); printf("the summation of the elements of the array is %d", result); return 0; } // to be completed by you :) int fillTheArrayFromFile(char fileName[], int array[]) {} int sum(int array[], int startIndex, int endIndex) {} 

c. [Finding the sum of elements of an array] For this question, you need to implement two functions i. Write a function which reads the numbers from the file and fills the array and returns the size of the array. The format of the file is as follows: the first number indicates how many numbers, the array should keep. For example, the following file, has 5 numbers and the array should be filled with the values 53, 23, 85, 90, 30. The numbers are separated by space. 5 53 23 85 90 30 The header of the function should be int fillTheArrayFromFile(char fileNameD, int arrayD); HANDLING ERROR] in case the program can't open the file successfully, the function should return -1 [ASSUMPTION] The file can have at most 20 numbers ii. Write a recursive function which takes an input array and its star t and end indices and returns the sum of the elements of the array in the range [startlndex, endlndex]. The function header should be: int sum(int arrayl, int startindex, int endlndex); The main program MUST be as follows (and MUST NOT be changed at all)

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!