Colmwise web print (all tast cases not clear)

import java.util.*;
public class Main {
public static void main(String args[]) {

Scanner s=new Scanner(System.in);

	int rows=s.nextInt();
	System.out.print(rows+" ");
	
	int cols=s.nextInt();
	System.out.print(cols);
	System.out.println();
	int arr[][]=new int[rows][cols];
	for(int i=0;i<rows;i++)
	{
		for(int j=0;j<cols;j++)
		{
			arr[i][j]=s.nextInt();
		}
	}
	for(int i=0;i<rows;i++)
	{
		for(int j=0;j<cols;j++)
		{
			System.out.print(arr[i][j]+" ");
		}
		System.out.println();
	}
	
	
	for(int j=0;j<arr.length;j++)
	{
			if(j%2==0)
				
			{
				for(int i=0;i<arr.length;i++)
				{
					System.out.print(arr[i][j]+", ");
				}
				
			}
			else
			{
				for(int i=arr.length-1;i>=0;i--)
				{
					System.out.print(arr[i][j]+", ");
				}
				
				
			}
		
	}
	System.out.print("End");

}

}

Hey @Ajstar,
Your logic is correct
You are printing extra lines in your code.
Remove them:

Pay close attention to the expected output format.
Also, your indexing of for loop isn’t correct .

At last, it should be END not End

Here’s your updated code.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.