//Calculate the average marks from an array for using each loop

 



public class CDM_P6 {
public static void main(String[] args) {
float []mark = {56.9f,67.8f,78.9f,90.4f,34.9f};
float sum = 0;
for(float element:mark){
sum = sum + element
;
}
System.
out.println("The value of average marks is :"+sum/mark.length );

}
}

//output
The value of average marks is :65.78 Process finished with exit code 0



Post a Comment

0 Comments