A super Anticlockwise Circular Matrix program
Anticlockwise Circular Matrix program: solved Java program for ISC Class 11 Computer Science with complete BlueJ code, explanation and sample output.
Circular matrix is a way to fill the matrix from the center towards the boundary elements in clockwise or anticlockwise manner.
Write a program to accept the size of the matrix from the user and make an anticlockwise circular matrix (full the data in the matrix from the center to the boundary in an anti clock wise pattern) and print it.
To learn more about how to take input using BufferedReader in java watch the given video.
https://youtu.be/bTOMwnwpXqs
import java.util.*;
class AnticlockMatrix
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the size of the matrix: ");
int n = sc.nextInt();
int A[][] = new int[n][n];
int k=n*n, c1=0, c2=n-1, r1=0, r2=n-1;
while(k>=1)
{
for(int i=c1;i<=c2;i++)
{
A[r1][i]=k--;
}
for(int j=r1+1;j<=r2;j++)
{
A[j][c2]=k--;
}
for(int i=c2-1;i>=c1;i--)
{
A[r2][i]=k--;
}
for(int j=r2-1;j>=r1+1;j--)
{
A[j][c1]=k--;
}
c1++;
c2--;
r1++;
r2--;
}
System.out.println("The Circular Matrix is:");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(A[i][j]+ "\t");
}
System.out.println();
}
}
}Output:
Enter the order : 4
The Circular Matrix is:
16 15 14 13
5 4 3 12
6 1 2 11
7 8 9 10
To learn more matrix programs click
A Simple program: Sum of Boundary elements of a Matrix
Related Posts
Continue learning with these related articles

ISC Practical 2027: Image Editor – Brighten an Image and Find Bright Spots (2-D Array) – Java Program
Fully solved ISC Computer Science Practical 2027 2-D array question: brighten a grayscale image (capping values at 255) and find the bright spots, pixels larger than all four neighbours. Includes a missing bright spot in CISCE’s sample output.

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.