/* This is HW4_6 Lab EE107
The purpose of this function to takes the sum of two arguments in an array.
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Due Date: April 26th, 2024.
*/
#include <stdio.h>
// Function to calculate the sum of elements in an array
int arraysum_EU(int arr_EU[], int size_EU) {
int sum_EU = 0;
// Iterate through the array and accumulate the sum
for (int i_EU = 0; i_EU < size_EU; i_EU++) {
sum_EU += arr_EU[i_EU];
}
return sum_EU;
}
int main() {
int array_EU[] = {5, 12, 36, 45, 57}; // Sample array
int size_EU = sizeof(array_EU) / sizeof(array_EU[0]); // Calculate the size of the array
// Calculate the sum of elements in the array
int sum_EU = arraysum_EU(array_EU, size_EU);
// Print the sum
printf("Sum of elements in the array: %d\n", sum_EU);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: