#include <stdio.h>
// Function to calculate the sum of an array of integers
int sum_of_numbers(int numbers[], int size)
{
int total = 0; // Initialize the sum variable to 0
// Loop through the array and add each number to the total
for (int i = 0; i < size; i++)
{
total += numbers[i];
}
return total;
}
int main()
{
int numbers[10];
// Ask the user to enter 10 integers
printf("Enter 10 integers:\n");
for (int i = 0; i < 10; i++)
{
scanf("%d", &numbers[i]);
}
// Call the sum_of_numbers function and print the result
int sum = sum_of_numbers(numbers, 10);
printf("The sum of the numbers is: %d\n", sum);
return 0;
}
Output