TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Square Matrix Program in Java
Alagunila Meganathan
Aug 02
2016
Code
19.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
SquareMatrix.rar
public
class
SquareMatrix {
public
static
void
main(String[] args) {
int
square[][]= {{
1
,
3
,
5
},{
2
,
4
,
6
}};
System.out.println(
"Your Original Matrix: "
);
for
(
int
i =
0
; i <
2
; i++){
for
(
int
j =
0
; j <
3
; j++){
System.out.print(square[i][j] +
" "
);
}
System.out.println();
}
for
(
int
i =
0
; i <=
1
; i++) {
for
(
int
j =
0
; j <=
2
; j++) {
square[i][j] = square[i][j] * square[i][j];
}
}
System.out.println(
"Matrix after changes: "
);
for
(
int
i =
0
; i <
2
; i++){
for
(
int
j =
0
; j <
3
; j++){
System.out.print(square[i][j] +
" "
);
}
System.out.println();
}
}
}
Java