Thursday, December 4, 2014

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











1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdlib.h>

int ArraySum(int MyArray[],int size)
{
    int sum = 0;
   for(int i=0; i < size ;i++)
  {
     ///sum = sum + MyArray[i];
     sum += MyArray[i];
  }
    return sum;
}
int main()
{
  int MyNumberArray [8] = {20,30,60,50,55,30,100,100};///245 +100 +100 =445
  int sum_of_array = ArraySum(MyNumberArray, 8);

  printf("Arra Sum = %d ",sum_of_array);

}








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

No comments:

Post a Comment