C Programming for Beginners 20 - Passing Arrays as Function Arguments in C

preview_player
Показать описание
My Websites -

passing array as argument to function in c
C Programming Arrays and Functions
C passing entire array to function
C passing array element to function
Passing array to function in C programming with example
How to pass a 2D array as a parameter in C?
Pass array to function : Array Parameter
Arrays as function arguments
Passing Array Elements and Whole Array to a Function
Рекомендации по теме
Комментарии
Автор

#include <stdio.h>
#include <stdlib.h>
int ArraySum(int MyArray[], int size)
{
int sum = 0, i = 0;
for(i; i < size; i++)
{
sum += MyArray[i];
}
return sum;
}

int main()
{
int MyNumberArray[6] = {20, 30, 60, 50, 55, 30};
int sizeOfArray = sizeof MyNumberArray / sizeof MyNumberArray[0];
int sumOfArray = ArraySum(MyNumberArray, sizeOfArray);
printf("The sum of the elements in array is = %d\n", sumOfArray);
return 0;
}

joelisaacm
Автор

Don't you have to declare the function first????

musmansiddique
Автор

i cant run this it shows error every time.

chiiraagp
Автор

This program is not working on turboC. It shows error.

ashen_vortex