Created
January 15, 2017 19:55
-
-
Save muaddib1971/87a86200ea6903c4d7117693b7e8162f to your computer and use it in GitHub Desktop.
example of passing an array to a function in c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int doit(int array[]) | |
| { | |
| int i; | |
| int sum=0; | |
| for(i = 0; i < 10 ; ++i) | |
| { | |
| sum += array[i]; | |
| } | |
| return sum; | |
| } | |
| int main(void) | |
| { | |
| int array[10] = {1,2,3,4,5,6,7,8,9,0}; | |
| printf("%d\n", doit(array)); | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment