Page 269 - computer science (868) class 11
P. 269

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


                 10.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;



                                                                                                                       267
                                                                                                              Arrays   267
   264   265   266   267   268   269   270   271   272   273   274