Assignment 3
Assignment 3
(1) The sum of an array is the sum of its individual elements. For
example, if an array is numbers = {1, 2, 3, 4}, the sum of the array
is 1+2+3+4 = 10.
Function Description: Complete the function summation. The
function must return the integer sum of the numbers array.
int summation(int numbers_size, int* numbers)
(3) Write a C function that use the bubble sort algorithm to sort
an integer array in ascending order (search for the bubble sorting
algorithm).
(4) Write a C function that use the selection sort algorithm to sort
an integer array in ascending order (search for the selection
sorting algorithm).
(7) Write a program that computes the nth term of the arithmetic
series:
1, 3, 5, 7, 9, …
Run the program to compute the 100th term of the given series.
(8) Write a program that computes the nth term of the geometric
series:
1, 3, 9, 27, …
Run the program to compute the 10th term of the given series.
(16) Write a C function that takes an array as input and reverse it.
Example:
Input : 1,2,3,4,5
Output: 5,4,3,2,1
a. Old array.
b. Old array size.
c. New array (empty array).
d. The size of the new array after fill it in the function.
int removeDuplicates(int arr_old[], int n_old, int arr_new[], int
*n_new)
Example:
arr1 = {1,2,3,3,3,4,4,5,5,5} → arr2 = {1,2,3,4,5}