0% found this document useful (0 votes)
77 views2 pages

270 Degree Array Rotation

program of 270 degree array rotation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views2 pages

270 Degree Array Rotation

program of 270 degree array rotation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

package array;

import java.util.*;
class RotationBy270DegreeClockwise
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("ENTER THE NUMBER OF ROWS : ");
int m=sc.nextInt();
System.out.print("ENTER THE NUMBER OF COLUMNS : ");
int n=sc.nextInt();
if((m>2 && m<10)||(n>2 && n<10))
{
int A[][]=new int[m][m];
/* Inputting the matrix */
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print("Enter an element : ");
A[i][j]=sc.nextInt();
}
}
/* Printing the original matrix */
System.out.println("OUTPUT : ORIGINAL MATRIX");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(A[i][j]+"\t");
}
System.out.println();
}
/* Rotated matrix */
System.out.println("MATRIX AFTER ROTATION");
for(int i=0;i<m;i++)
{
for(int j=n-1;j>=0;j--)
{
System.out.print(A[j][i]+"\t");
}
System.out.println();
}
// Finding sum of odd elements

int sum = 0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if (A[i][j]%2!=0);
{
sum = sum + A[i][j];
}

}
}
System.out.println("SUM OF ODD ELEMENTS " +sum);
}
else
{
System.out.println("SIZE OUT OF RANGE");
}
}
}

You might also like