[Solved] Output the array so that 10 elements per line are printed

[ad_1]

You have not called print method from main method. One more mistake is in your code that, you mentioned about 3 times of index variable and in your code you are taking cube of index variable.

public class progprblm5{
     public static void main(String []args){
         double alpha[] = new double[50];
         for(int i =0;i<25;i++){
             alpha[i]= i*i;
         }
         for(int i = 25;i<50;i++){
             alpha[i]= 3*i;  // 3 times of index
         }
         System.out.println( "The values are: ");

         new progprblm5().print(alpha);  // method call
}
  void print(double array[]){
      for(int i=0; i < array.length; i++){ //iterate array from 0 index
            System.out.print(array[i]+ " , "); // print ith element
            if(i%10==0){
              System.out.println();
            }
      }
 }    
}

[ad_2]

solved Output the array so that 10 elements per line are printed