Hey all,

I am having trouble understanding all of this code to give the sum of n numbers. I think I understand most of it, but there are a few lines which don't make too much sense to me. If anyone could dive deeper into an explanation that would be great!

Thanks

Code:#include <stdio.h> #include <conio.h> int main () { int i, a[10], sum=0, n;//declares integers i, a[10] (a single demensional array* subscript), sum=0 (to initialize), and n printf("Enter the amount of numbers:");//prompts user to enter the desired amount of numbers scanf("%d", &n);//reads the input from the keyboard printf("Enter the numbers\n");//prompts user to enter the actual numbers as an array for(i=0; i<n; i++)//for loop: for i, i=0, i<n (the desired amount of numbers), and i incremented { scanf("%d", &a[i]);//scans input from keyboard and the array specifications entered by user as defined by the ints i } for(i=0; i<n; i++)//for loop: for i, i=0, i<n (the desired amount of numbers), and i incremented printf("%d", a[i]);//prints... I can't understand this linefor(i=0; i<n; i++)//for loop: for i, i=0, i<n (the desired amount of numbers), and i incremented { sum=sum+a[i];//regarding for loop, sum now = sum (0) + the array specifications entered by user as defined by the ints i } printf("sum=\t%d", sum);//prints the sum calculated by the previous for loops return 0;//Can't understand this line either_getch();Can't understand this line either} //*a one dimensional array subscript which is a data script that allows the collection of variables each defined by one or more integer indices. //can store ten elements in it (0-9). Array indices always begin at the int 0 in C programming.