I know there are some serious issues with this program, please help correct it.
What I want the program to do is to scan an array of numbers and use function to calculate the sum
Code:
/"Program to enter a list of number and perform their addition using function"/
#include<stdio.h>
int addn(int b[])
{
int i=1; /"initialize i to 1"/
int sum=0;
sum+= b[i];
return sum;
}
main()
{
int j, n, a[20];
int result;
printf("Enter the count of numbers to be added:\n");
scanf("%d", &n); /"The
for(j=1;j<=n;j++)
{
scanf("%d", &a[j]); /"number input"/
printf("Entered numbers are: %10d\n", a[j]); /"Display the entered numbers"/
printf("Performing addition\n");
result= addn(a);
}
printf("The sum is :%d", result); /"Display the result"/
return 0;
}