1 Passing Array Array’s element can be passed individually to a function; copying value exist during passing process. An entire array can be passed to a function as a reference (by giving name of the array); copying value is not exist during passing process.
2 Example of Passing Array Elements #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); }
3 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements ??? i [0] [1] [2] number _
4 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements ??? i [0] [1] [2] number Enter three numbers(1-3): _
5 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 0 i ??? [0] [1] [2] number Enter three numbers(1-3): _
6 Example of Passing Array Elements 0 i ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _ 0<3 TRUE
7 Example of Passing Array Elements 0 i 1 ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 _
8 Example of Passing Array Elements 1 i 1 ??? [0] [1] [2] nombor #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 _
9 Example of Passing Array Elements 1 i 1 ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 _ 1<3 TRUE
10 Example of Passing Array Elements 1 i 1 3 ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 3 _
11 Example of Passing Array Elements 2 i 1 3 ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 3 _
12 Example of Passing Array Elements 2 i 1 3 ??? [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): 1 3 _ 2<3 TRUE
13 Example of Passing Array Elements 2 i [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _
14 Example of Passing Array Elements 3 i [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _
15 Example of Passing Array Elements 3 i [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _ 3<3 FALSE
16 Example of Passing Array Elements 0 i [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _
17 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 0 i [0] [1] [2] number Enter three numbers(1-3): _ 0<3 TRUE
18 Example of Passing Array Elements 0 i [0] [1] [2] number #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _
19 Example of Passing Array Elements 0 i [0] [1] [2] nombor #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Enter three numbers(1-3): _ 1 a
20 Example of Passing Array Elements Enter three numbers(1-3): _ 1 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 1==1 TRUE
21 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 1 a Enter three numbers(1-3): One_
22 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements Enter three numbers(1-3): One _ 0 i [0] [1] [2] number
23 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 1 i [0] [1] [2] number Enter three numbers(1-3): One _
24 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 1 i [0] [1] [2] number Enter three numbers(1-3): One _ 1<3 TRUE
25 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 1 i [0] [1] [2] number Enter three numbers(1-3): One ___
26 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 1 i [0] [1] [2] number Enter three numbers(1-3): One __ 3 a
27 Example of Passing Array Elements Enter three numbers(1-3): One _ 3 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 3==3 FALSE
28 Example of Passing Array Elements Enter three numbers(1-3): One _ 3 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 3==2 FALSE
29 Example of Passing Array Elements Enter three numbers(1-3): One __ 3 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 3==3 TRUE
30 Example of Passing Array Elements Enter three numbers(1-3): One Three _ 3 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); }
31 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements Enter three numbers(1-3): One Three _ 1 i [0] [1] [2] number
32 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 2 i [0] [1] [2] number Enter three numbers(1-3): One Three _
33 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 2 i [0] [1] [2] number Enter three numbers(1-3): One Three _ 2<3 TRUE
34 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 2 i [0] [1] [2] number Enter three numbers(1-3): One Three _
35 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 2 i [0] [1] [2] nombor Enter three numbers(1-3): One Three _ 2 a
36 Example of Passing Array Elements Enter three numbers(1-3): One Three _ 2 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 2==3 FALSE
37 Example of Passing Array Elements Enter three numbers(1-3): One Three _ 2 a #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } 2==2 TRUE
38 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements Enter three numbers(1-3): One Three Two _ 2 a
39 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements Enter three numbers(1-3): One Three Two _ 2 i [0] [1] [2] number
40 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 3 i [0] [1] [2] number Enter three numbers(1-3): One Three Two _
41 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 3 i [0] [1] [2] number Enter three numbers(1-3): One Three Two _ 3<3 FALSE
42 #include void To_Word(int a); int main() { int number[3], i; printf(“Enter three numbers(1-3): "); for (i=0; i < 3; i++) scanf("%d", &number[i]); for (i=0; i < 3; i++) To_Word(number[i]); } void To_Word(int a) { if (a == 1) printf(“One"); else if (a == 2) printf(“Two "); else if (a == 3) printf(“Three "); else printf("? “); } Example of Passing Array Elements 3 i [0] [1] [2] number Enter three numbers(1-3): One Three Two
43 Example of Passing Entire Array #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Cout_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } Read three numbers
44 Example of Passing Entire Array Calculate average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
45 Example of Passing Entire Array Print average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
46 Example of Passing Entire Array Calculate average from array of num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
47 Example of Passing Entire Array Add all the value of num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
48 Example of Passing Entire Array Calcalate the average of num and send to the function call #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
49 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } Example of Passing Entire Array ??? i [0] [1] [2] number _ ??? average
50 Example of Passing Entire Array 0 i ??? [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
51 Example of Passing Entire Array 0 i ??? [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 0<3 TRUE
52 Example of Passing Entire Array 0 i 55 ??? [0] [1] [2] number 55 _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
53 Example of Passing Entire Array 1 i 55 ??? [0] [1] [2] number 55 _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
54 Example of Passing Entire Array 1 i 55 ??? [0] [1] [2] number 55 _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 1<3 TRUE
55 Example of Passing Entire Array 1 i ??? [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
56 Example of Passing Entire Array 2 i ??? [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
57 Example of Passing Entire Array 2 i ??? [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 2<3 TRUE
58 Example of Passing Entire Array 2 i [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
59 Example of Passing Entire Array 3 i [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
60 Example of Passing Entire Array 3 i [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 3<3 FALSE
61 Example of Passing Entire Array 3 i [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
62 Example of Passing Entire Array 3 i [0] [1] [2] number _ ??? average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
63 Example of Passing Entire Array 3 i [0] [1] [2] number _ ??? average 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
64 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num 0 ??? #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } total_num i
65 Example of Passing Entire Array [0] [1] [2] number _ #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 3 bil num 0 i 0 total_num
66 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num 0 0 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 0<3 TRUE
67 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num 0 0 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 55
68 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num 55 1 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num
69 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num 55 1 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 1<3 TRUE
70 Example of Passing Entire Array [0] [1] [2] number _ 3 bil nom 55 1 #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 120
71 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num
72 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 2<3 TRUE
73 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 150
74 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num
75 Example of Passing Entire Array [0] [1] [2] number _ 3 bil num #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } i total_num 3<3 FALSE
76 Example of Passing Entire Array [0] [1] [2] number _ #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; } 3 bil num 150 total_num i
77 Example of Passing Entire Array [0] [1] [2] number _ 3 i average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
78 Example of Passing Entire Array [0] [1] [2] number Average : _ 3 i average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
79 Example of Passing Entire Array [0] [1] [2] number Average : _ 3 i average #include float Count_Average(int nom[], int bil); void main() { int number[3], i; float average; for (i=0; i < 3; i++) scanf("%d", &number[i]); average = Count_Average(number, 3); printf(“Average : %.2f\n", average); } float Count_Average(int num[], int bil) { int i, total_num= 0; for (i=0; i < bil; i++) total_num+= num[i]; return (float) total_num/ bil; }
80 Global Array Array is a global if it is declared by out of defined function. Global array can be accessed anywhere. Another words, function which access global array no need to declare any parameter for them.
81 Example of Global Array #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
82 Example of Global Array ??? [0] [1] [2] num _ #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
83 Example of Global Array ??? [0] [1] [2] num _ ??? i average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
84 Example of Global Array ??? [0] [1] [2] num _ 0 i ??? average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
85 Example of Global Array ??? [0] [1] [2] num _ 0 i ??? average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; } 0<3TRUE
86 Example of Global Array [0] [1] [2] num _ 3 i ??? average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
87 Example of Global Array [0] [1] [2] num _ 3 i ??? average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
88 Example of Global Array [0] [1] [2] num _ 3 i ??? average #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
89 Example of Global Array [0] [1] [2] num _ 3 i ??? average 3 bil #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; }
90 Example of Global Array [0] [1] [2] num _ 3 bil 0 ??? #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; } total i
91 Example of Global Array [0] [1] [2] num _ 3 bil #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; } 0 total i 0
92 Example of Global Array [0] [1] [2] num _ 3 bil 0 0 #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; } total i 0<3 TRUE
93 Example of Global Array [0] [1] [2] num _ 3 bil 55 0 #include int num[3]; float Count_Average(int bil); void main() { int i; float average; for (i=0; i < 3; i++) scanf("%d", &num[i]); average= Count_Average(3); printf(“Average : %.2f\n", average); } float Count_Average(int bil) { int i, total= 0; for (i=0; i < bil; i++) total+= num[i]; return (float) num/ bil; } total i