Question: 1. Write an int function to open and read words (i.e. strings) from a text file. The function will return the number of words that

1. Write an int function to open and read words (i.e. strings) from a text file. The function will return the number of words that has an even length or will return-1 in case something goes wrong (no file or empty file). The function receives the name of the file as an argument. Don't forget to close the file in the end. 2. Write an int function to return the average of the int numbers in a binary file. Assume the values are positive and return -1 in case something goes wrong (no file or empty file). The function receives the name of the file as an argument. Do it efficiently for full credit! 3. Write a void function to convert a binary file, which has nodes (type NODE) with an integer, a string, and a next pointer, to a text file with integers and strings. The text file should have an integer and a string in each line. The function receives the pointers to both files, bfp and tfp (type FILE *). 4. Write a recursive int function that will calculate the sum of natural numbers. The function will receive a positive integer as an argument and will work according to the definition below. Note to myself: sum(3) = 6 If n = 0, sum(n) = 0 if n > 0, sum(n)= n + sum(n-1) 5. Explain what is function fun doing. What would be the final number returned if x = 5 and y = 2? int fun (int x, int y) { if (x == 0) return y; else return fun1(x } 1, x + y)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
