St Xavier's College, Jaipur
(Affiliated to The University of Rajasthan)
(Approved under Section 2(f) and 12(B) of UGC Act, 1956)
A Christian Minority Educational Institution under Section 2(g) of NCMEI Act, 2004
Mahapura Road, Nevta, Rajasthan-302029
Notice
Life @ Xavier's
Timings
Office Timings:7:30 AM to 3:00 PM
College Timings:8:00 AM to 2:30 PM
Website:www.stxaviersjaipur.org
About Xavier's College, Jaipur [ SXCJ ]
In 2010, the J.X.E.A. (Jaipur Xavier Educational Association) in collaboration with the Xavier Alumni/ae and the well-wishers of Jaipur under the leadership of Rev. Fr. Varkey Perekkatt, S.J., initiated their journey into Higher Education by establishing St. Xavier's College, Jaipur . The aim was to continue the work that St. Xavier wanted to do–promote human fulfilment by means of training and education in India. Following the motto of the founder of the Society of Jesus, St. Ignatius, the college has been working for “the greater glory of God” (Ad majorem dei gloriam).
About Department of Computer Science
Department of Computer Science (B.C.A.) course curriculum aims at providing a preliminary yet inclusive view of established and emerging IT areas in diverse scientific fields with application-oriented approach and problem-solving skills to create technically knowledgeable and ethically cognizant graduates in the field of Computer Science. Department of Computer Science provides a platform to the students to work on core concepts blended with latest technologies.
Our Blog
Technoid 2022
TECHNOID'22: Transcending Horizons, "Tech-it to the future"
TECHNOID'22: Transcending Horizons, "Tech-it to the future"
GAMERS LEAGUES (GAMING)
RETRO RUN(GAMING)
TECHNOID PREMIER LEAGUE (TPL)
CODESMASH (DEBUGGING]
ROBOIGNITORS [ROBOTIC]
UNLOCK-IT (TECH QUIZ)
ARTICISIE (GRAPHIC DESIGNING)
PEXELS [ONLINE PHOTOGRAPHY)
ORIGINATION [PRODUCT LAUNCH)
Top 10 Frequently Asked Pattern Programs in Java
In this post, "Top 10 Frequently Asked Pattern Programs in Java", we will look at some of the most commonly asked pattern questions. These questions are one of the most common questions asked by teachers and interviewers. To understand the program to print pattern, it is important to have some knowledge and coding skills—and if you're looking for a good way to improve your coding skills in Java, then this post is for you!
Top 10 Frequently Asked Pattern Programs in Java
Java Ques 1: Program in Java to print right angle triangle using * sign.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Demosxcpattern{ public static void main(String args[]){ int row=5; System.out.println("pattern using *\n"); for(int i=0; i<row; i++) { for(int j=0; j<=i; j++) { System.out.print("* "); } System.out.println(); } } } |
Java Ques 2: Program in java to print pyramid pattern using * sign.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | public class Demosxcpattern{ public static void main(String args[]) { int sp,star=0; int rows=8; System.out.println("star pattern pyramid\n"); //outer loop for printing rows for(int i = 1; i <= rows; i++) { // print leading space for(sp = 1; sp <= rows-i; sp++) { System.out.print(" "); }// print star while(star != (2*i - 1)){ System.out.print("*"); star++; } star=0; // move to next row System.out.print("\n"); } } } |
Java Ques 3: Program in Java to print inverted right triangle star pattern using * sign.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Demosxcpattern{ public static void main(String args[]) { System.out.println("Pattern \n "); for(int i = 8; i > 0; i--) { /* Prints one row of triangle */ for(int j = i; j > 0; j--) { System.out.print("* "); } System.out.print("\n"); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class demosxcpascal { public static void main(String[] args) { int row=7, i, j, space, number; for(i=0; i<row; i++) { for(space=row; space>i; space--) { System.out.print(" "); } number=1; for(j=0; j<=i; j++) { System.out.print(number+ " "); number = number*(i-j)/(j+1); } System.out.print("\n"); } } } |
Java Ques 4: Program in Java to print the following pattern
010101
101010
010101
101010
010101
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | public class demosxcpattern { public static void main(String args[]) { int n; System.out.println("pattern program \n"); for(int i = 1; i <= 5; i++) { if(i%2 == 0) { n = 0; for(int j = 1; j <= 6; j++) { System.out.print(n); n = (n == 0)? 1 : 0; } } else { n = 1; for(int j = 1; j <= 6; j++) { System.out.print(n); n = (n == 0)? 1 : 0; } } System.out.println(); } } } |
Output:-
Java Ques 5: Program in Java to print the following pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public class demosxcpattern { public static void main(String args[]) { System.out.println("Pattern Program \n"); for(int i = 1; i <= 6; i++) { for(int j = 6-i; j < 5; j++) { System.out.print(" "); } for(int k = i; k <= 6; k++) { System.out.print(k); } System.out.println(); } } } |
Java Ques 6: Program in Java to print the following pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public class demosxcpattern { public static void main(String args[]) { int t = 1; System.out.println("pattern program \n"); for(int i = 5; i >= 1; i--) { for(int j = 1; j <= i; j++) { System.out.print(t++ + " "); } System.out.println(); } } } |
Java Ques 7: Program in Java to print the following pattern
11 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | public class demosxcpattern { public static void main(String[] args) { int rows = 5; System.out.println("Pattern Program"); for (int i = 1; i <= rows; i++) { for (int j = 1; j <= i; j++) { System.out.print(j+" "); } System.out.println(); } //Printing lower half of the pattern for (int i = rows-1; i >= 1; i--) { for (int j = 1; j <= i; j++) { System.out.print(j+" "); } System.out.println(); } } } |
Output:-
Java Ques 8: Program in Java to print the following pattern
12 2
3 3 3
4 4 4 4
5 5 5 5 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public class demosxcpattern { public static void main(String[] args) { int rows = 5; System.out.println("Pattern Program"); for (int i = 1; i <= rows; i++) { for (int j = 1; j <= i; j++) { System.out.print(i+" "); } System.out.println(); } } } |
Java Ques 9: Program in Java to print the following pattern
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class demosxcpattern { public static void main(String[] args) { int rows = 5; System.out.println("Pattern Program \n"); for (int i = rows; i >= 1; i--) { for (int j = i; j >= 1; j--) { System.out.print(j+" "); } System.out.println(); } } } |
Java Ques 10: Program in Java to print the following pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public class demosxc { public static void main(String[] args) { int rows = 5; System.out.println("Pattern Program \n"); //for upper pattern for (int i = rows; i >= 1; i--) { for (int j = 1; j <= i; j++) { System.out.print(j+" "); } System.out.println(); } //for lower for (int i = 2; i <= rows; i++) { for (int j = 1; j <= i; j++) { System.out.print(j+" "); } System.out.println(); } } } |