Download presentation
Presentation is loading. Please wait.
1
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
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
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
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
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
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
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
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
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
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
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
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
13 Example of Passing Array Elements 2 i 1 3 2 [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 _
14
14 Example of Passing Array Elements 3 i 1 3 2 [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 _
15
15 Example of Passing Array Elements 3 i 1 3 2 [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<3 FALSE
16
16 Example of Passing Array Elements 0 i 1 3 2 [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 _
17
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 _ 0<3 TRUE
18
18 Example of Passing Array Elements 0 i 1 3 2 [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 _
19
19 Example of Passing Array Elements 0 i 1 3 2 [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 3 2 _ 1 a
20
20 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 _ 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
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): 1 3 2 One_
22
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): 1 3 2 One _ 0 i 1 3 2 [0] [1] [2] number
23
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One _
24
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One _ 1<3 TRUE
25
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One ___
26
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One __ 3 a
27
27 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
28 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
29 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
30 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
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): 1 3 2 One Three _ 1 i 1 3 2 [0] [1] [2] number
32
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three _
33
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three _ 2<3 TRUE
34
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three _
35
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 1 3 2 [0] [1] [2] nombor Enter three numbers(1-3): 1 3 2 One Three _ 2 a
36
36 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
37 Example of Passing Array Elements Enter three numbers(1-3): 1 3 2 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
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): 1 3 2 One Three Two _ 2 a
39
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): 1 3 2 One Three Two _ 2 i 1 3 2 [0] [1] [2] number
40
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three Two _
41
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three Two _ 3<3 FALSE
42
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 1 3 2 [0] [1] [2] number Enter three numbers(1-3): 1 3 2 One Three Two
43
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
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
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
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
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
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
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
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
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
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
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
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
55 Example of Passing Entire Array 1 i 55 65 ??? [0] [1] [2] number 55 65 _ ??? 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
56 Example of Passing Entire Array 2 i 55 65 ??? [0] [1] [2] number 55 65 _ ??? 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
57 Example of Passing Entire Array 2 i 55 65 ??? [0] [1] [2] number 55 65 _ ??? 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
58 Example of Passing Entire Array 2 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
59 Example of Passing Entire Array 3 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
60 Example of Passing Entire Array 3 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
61 Example of Passing Entire Array 3 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
62 Example of Passing Entire Array 3 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
63 Example of Passing Entire Array 3 i 55 65 30 [0] [1] [2] number 55 65 30 _ ??? 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
64 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
65 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ #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
66 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
67 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
68 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
69 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
70 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 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
71 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 bil num 120 2 #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
72 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 bil num 120 2 #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
73 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 bil num 120 2 #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
74 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 bil num 150 3 #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
75 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 bil num 150 3 #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
76 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 50.000000 #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
77 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 _ 3 i 50.000 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
78 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 Average : 50.00 _ 3 i 50.000 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
79 Example of Passing Entire Array 55 65 30 [0] [1] [2] number 55 65 30 Average : 50.00 _ 3 i 50.000 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
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
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
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
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
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
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
86 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
87 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
88 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
89 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
90 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
91 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
92 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
93 Example of Global Array 55 65 30 [0] [1] [2] num 55 65 30 _ 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.