The C program below uses THREE (3) functions: getNumbers(), printNumbers() and sumNumbers().
int myArray[100]; int main(void){ int numint, result; printf("How many numbers to be entered? "); scanf("%d", &numint); getNumbers(numint); printNumbers(numint); result = sumNumbers(numint); printf("Sum of numbers entered = %d", result); return 0; }
- Based on the program written above, write down the function prototypes for the THREE (3) functions.
- Write the function getNumbers(). This function is supposed to ask user for a list of integers and store them in the array named myArray. The number of integers to be entered is passed as the actual parameter.
- Write the function printNumbers(). This function is supposed to print out the integers inside the array. The number of integers stored in the array is passed as the actual parameter.
- Write the function sumNumbers(). This number is supposed to sum up all the integers inside the array. The number of integers stored in the array is passed as the actual parameter. The function must return an integer which is the result of the summation.
没有评论:
发表评论