1 Array Knowledge Understand the execute technique of array Skill Can write application program using one and two dimensional array
2 Why Array? Assume that you were asked to write a program that accept 10 student marks, calculating average mark, and then print a number of students that get more than average mark. How to store all these marks?
#include void main() { int mark1, mark2, mark3, mark4, mark5, mark6, mark7, mark8, mark9, mark10; int bil=0, total_mark = 0; float Average_mark; printf(“\nRead 10 test marks : \n”); scanf(“%d%d%d%d%d%d%d%d%d%d”, &mark1, &mark2, &mark3, &mark4, &mark5, &mark6, &mark7, &mark8, &mark9, &mark10); total_mark = mark1 + mark2 + mark3 + mark4 +mark5 + mark6 + mark7 + mark8 + mark9 + mark10; Average_mark = (float) total_mark/10; Read student marks Solving Without Using Array
#include void main() { int mark1, mark2, mark3, mark4, mark5, mark6, mark7, mark8, mark9, mark10; int bil=0, total_mark = 0; float Average_mark; printf(“\nRead 10 test marks : \n”); scanf(“%d%d%d%d%d%d%d%d%d%d”, &mark1, &mark2, &mark3, &mark4, &mark5, &mark6, &mark7, &mark8, &mark9, &mark10); total_mark = mark1 + mark2 + mark3 + mark4 +mark5 + mark6 + mark7 + mark8 + mark9 + mark10; Average_mark = (float) total_mark/10; Calculate the total mark
Solving Without Using Array Calculate the average mark #include void main() { int mark1, mark2, mark3, mark4, mark5, mark6, mark7, mark8, mark9, mark10; int bil=0, total_mark = 0; float Average_mark; printf(“\nRead 10 test marks : \n”); scanf(“%d%d%d%d%d%d%d%d%d%d”, &mark1, &mark2, &mark3, &mark4, &mark5, &mark6, &mark7, &mark8, &mark9, &mark10); total_mark = mark1 + mark2 + mark3 + mark4 +mark5 + mark6 + mark7 + mark8 + mark9 + mark10; Average_mark = (float) total_mark/10;
if (mark1 > Average_mark) bil++; if (mark2 > Average_mark) bil++; if (mark3 > Average_mark) bil++; if (mark4 > Average_mark) bil++; if (mark5 > Average_mark) bil++; if (mark6 > Average_mark) bil++; if (mark7 > Average_mark) bil++; if (mark8 > Average_mark) bil++; if (mark9 > Average_mark) bil++; if (mark10 > Average_mark) bil++; printf(“\nAverage mark = %.2f”, purata); printf(“\n Number of students that get more than Average mark %d”, bil); } What would happen if there were 100 students? Solving Without Using Array Calculate number of students which get more than Average mark
Solving Without Using Array if (mark1 > Average_mark) bil++; if (mark2 > Average_mark) bil++; if (mark3 > Average_mark) bil++; if (mark4 > Average_mark) bil++; if (mark5 > Average_mark) bil++; if (mark6 > Average_mark) bil++; if (mark7 > Average_mark) bil++; if (mark8 > Average_mark) bil++; if (mark9 > Average_mark) bil++; if (mark10 > Average_mark) bil++; printf(“\nAverage mark = %.2f”, Average_mark); printf(“\n Number of students that get more than average mark = %d”, bil); } What would happen if there were 100 students? Print the result
8 One-dimensional Array Instead of using 10 variables to represent 10 student marks,another technique is using one-dimensional array for storing a list of marks. Array is a collection of memory location that is used for storing data from same type. Each memory location in array is referred by array’s name and location memory index.
9 One Dimensional Array 67 mark [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] For printing each mark in array: for (i=0; i < 10; i++) printf("%d ", mark[i]) Array name
10 One Dimensional Array 67 mark [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] For printing each mark in array: for (i=0; i < 10; i++) printf("%d ", mark[i]) Array Index
11 One-Dimensional Array Array declaration syntax data_type name_of_array[integer_expression]; Example: int mark[10]; In C programming, each index in array is start from 0. Thus, the last index number in one array of sized n is n-1.
12 Array Controlling One way for giving initial value to array’s element is giving a list of initial value in array declaration.
13 Array Controlling Example: int month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; month [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
14 Array Controlling If the list of initial value is less than array size, the rest element will be given 0 value int month[12] = { 31, 28, 31, 30, 31 } month [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] 0 0 [10] [11]
15 Array Controlling Array size can be ignore in declaration if it is given by initial value list. Array size will be set based on a number of data in their list. int month[ ] = { 31, 28, 31, 30, 31 } month [0] [1] [2] [3] [4]
16 Array Assignment Value assignment to array’s element is same as value assign to variable. Assignment to array can be done element by element.
17 Array Assignment Example: tinggi ??? [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68;
18 Array Assignment tinggi ??? [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68; Example:
19 Array Assignment tinggi ??? ??? [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68; Example:
20 Array Assignment tinggi ??? [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68; Example:
21 Array Assignment tinggi ??? [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68; Example:
22 Array Assignment tinggi [0] [1] [2] [3] [4] float tinggi[5]; tinggi[0] = 31.34; tinggi[1] = 28.11; tinggi[2] = 31.25; tinggi[3] = 30.94; tinggi[4] = 31.68; Example:
23 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i ??? int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
24 Array Assignment In certain situation, array assignment can be write using looping number ??? [0] [1] [2] [3] [4] i 0 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
25 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 0 int number[5], i; for (i=0; i < 5; i++) number[i] = 0; 0<5 TRUE
26 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? [0] [1] [2] [3] [4] i 0 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
27 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? [0] [1] [2] [3] [4] i 1 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
28 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? [0] [1] [2] [3] [4] i 1 int number[5], i; for (i=0; i < 5; i++) number[i] = 0; 1<5 TRUE
29 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? 0 [0] [1] [2] [3] [4] i 1 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
30 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? 0 [0] [1] [2] [3] [4] i 2 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
31 Array Assignment In certain situation, array assignment can be write using looping. number 0 ??? 0 [0] [1] [2] [3] [4] i 2 int number[5], i; for (i=0; i < 5; i++) number[i] = 0; 2<5 TRUE
32 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 2 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
33 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 3 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
34 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 3 int number[5], i; for (i=0; i < 5; i++) number[i] = 0; 3<5 TRUE
35 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 3 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
36 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 4 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
37 Array Assignment In certain situation, array assignment can be write using looping. number ??? [0] [1] [2] [3] [4] i 4 int number[5], i; for (i=0; i < 5; i++) number[i] = 0; 4<5 TRUE
38 Array Assignment In certain situation, array assignment can be write using looping. number [0] [1] [2] [3] [4] i 4 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
39 Array Assignment In certain situation, array assignment can be write using looping. number [0] [1] [2] [3] [4] i 5 int number[5], i; for (i=0; i < 5; i++) number[i] = 0;
40 Array Assignment In certain situation, array assignment can be write using looping. number [0] [1] [2] [3] [4] int number[5], i; for (i=0; i < 5; i++) number[i] = 0; i 5 5<5 FALSE
41 Array Assignment In certain situation, array assignment can be write using looping. number [0] [1] [2] [3] [4] int number[5], i; for (i=0; i < 5; i++) number[i] = 0; i 5
42 Example of Using Array Program to process 3 student mark Read students mark Calculate number of mark greater than Average mark Calculate Total mark All Students mark Calculate Average mark All Students mark Total mark Total mark Average mark All students Mark, Average mark number Print the result Average mark, number
Example of Using Array #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Read student marks
Example of Using Array #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Calculate total mark
Example of Using Array #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Calculate the average mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Calculate the number of student that get more than average mark
Example of Using Array #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Print the result
Example of Using Array #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } ??? i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 0 ??? i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 0 ??? i bil total_mark Average_mark [0] [1] [2] mark 0<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 0 ??? 70 ??? Enter mark 0: 70 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 1 ??? 70 ??? Enter mark 0: 70 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 1 ??? 70 ??? Enter mark 0: 70 i bil total_mark Average_mark [0] [1] [2] mark 1<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 1 ??? ??? Enter mark 0: 70 Enter mark 1: 30 i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 2 ??? ??? Enter mark 0: 70 Enter mark 1: 30 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 2 ??? ??? Enter mark 0: 70 Enter mark 1: 30 _ i bil total_mark Average_mark [0] [1] [2] mark 2<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 2 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 3 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 3 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 3<3 FALSE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 3 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of mark that are greater than average = %d\n”, bil); } Example of Using Array 0 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 0 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 0<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 0 ??? 70 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 1 ??? 70 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 1 ??? 70 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 1<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 1 ??? 100 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 2 ??? 100 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 2 ??? 100 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 2<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 2 ??? 180 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 3 ??? 180 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 3 ??? 180 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 3<3 FALSE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array 3 ??? Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 0<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 1<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 2<3 TRUE
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
#include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark
86 #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 _ i bil total_mark Average_mark [0] [1] [2] mark 3<3 FALSE
87 #include void main() { int mark[3], i, bil, total_mark; float Average_mark; for (i = 0; i < 3, i++) { printf(“Enter mark %d : “, i); scanf(“%d”, &mark[i]); } total_mark= 0; for (i = 0; i < 3; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 3; bil = 0; for (i = 0; i < 3; i++ ) if (mark[i] > Average_mark) bil++; printf(“\nAverage mark= %.2f”, Average_mark); printf(“\nNumber of students that get more than average mark = %d\n”, bil); } Example of Using Array Enter mark 0: 70 Enter mark 1: 30 Enter mark 2: 80 Average mark= Number of students that get more than average mark = 2 _ i bil total_mark Average_mark [0] [1] [2] mark