C Programming Tutorial - 52: Arrays (Part-2) Adding Array Elements

preview_player
Показать описание
In this tutorial we'll learn to use loops to access array elements, add them and also compute the average of the elements.
Рекомендации по теме
Комментарии
Автор

I complement your effort and time to upload all this dig and small time to educate us here way... off from modern world as this part of Africa we fine it difficult to reach such materials. thanks for your ideas share

SeptimusFodayKamara
Автор

heyy im having trouble adding the total of one array with the total of another..
please let me know if you could

for example adding all the values of x[4] with all the values of y[4] and printing out one value which is the total number of all values both in x[4] and y[4]

ragyquiteque
Автор

I honestly find it much easier to just assign some random valid placeholder value to the first element and ignore it, and then assign all the values that I actually want to use to all the other elements.
This makes the first value correspond to the number "1" in the array, and so on.
Much more natural.

Peter_
Автор

Its better when you write the code first then explain it

TheOperant
Автор

Please tell my why it keeps saying C90 excludes mixed declarations and code and keeps pointing me to the "int score[5]" line when telling me this?? This is a slightly modified version but I am just trying to figure arrays out

#include <stdio.h>

int main(void)

{
int i;
int total;
int score[5];
total = 0;

for(i=0;i<5;i++)
{
printf("Enter 5 numbers: ");
scanf("%d", &score[i]);
}

total=total+score[i];

printf("Row total = ", score);

return 0;

bigmacdoubleyouv