Page 293 - Cs_withBlue_J_C11_Flipbook
P. 293
10 System.out.println("Student Name\tStudent Marks");
11 for(i=0; i<len; i++)
12 {
13 System.out.println(stu_name[i]+ "\t\t" + stu_marks[i]);
14 total_marks = total_marks + stu_marks[i];
15 }
16 avg_marks=(double)total_marks/(double)len;
17 System.out.println("Total marks is: "+ total_marks);
18 System.out.println("Average Marks of the class is: "+ avg_marks);
19 }
20 }
To take input from the user:
The output of the preceding program is as follows:
Total number of students in the class: 5
----------------------------------------------------
Student Name Student Marks
Ramesh 90
Ram 95
Ayan 99
Ajoy 98
Baban 89
Total marks is: 471
Average Marks of the class is: 94.2
11.3.4 Length of the Array
The total number of elements an array holds is the length of the array. To find the total number of elements in the
array, we use the “length” property. This property returns an integer value. Syntax to use the length property is as
follows:
int len= name_of_array.length;
291
Arrays 291

