Hey guys I am a beginner in coding and I am stuck on some homework. I have done some of it, but I do not know how to a part. The instructions are as follows:
Declare an integer variable that will hold a sum and give it an initial
value of zero.
Declare a ten element integer array named myarray.
Using a printf/scanf pair in a for loop, input integers into the ten
elements of the array.
Use a second for loop to compute the sum of the ten values, storing
the result in the variable you created in the first step.
Use a single printf to display "The sum is: " followed by the value
your program computed as the sum. End the line with a newline
character. Notice the space character following the colon. This
provides space that makes reading your output a little easier.
I have this so far:
Code:
#include <stdio.h>#include <conio.h>
void main()
{
int myarray[10] = {1,2,3,4,5,6,7,8,9,9};
int i;
int total=0;
for(i=0; i<10; i++)
{
total +=myarray[i];
}
printf("The toal is %d", total);
}
How do I do the third bullet, where the user can input 10 intgers?