Square Pattern

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 33:- Square Pattern

Here's an example of how to create a square pattern using loops in Java:

markdownCopy code
***** ***** ***** ***** *****
javaCopy code
public class SquarePattern { public static void main(String[] args) { int n = 5; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { System.out.print("*"); } System.out.println(); } } }

In the program above, we use two nested loops to create the square pattern. The outer loop runs n (5 in this case) times, representing the number of rows, and the inner loop prints the asterisks n times, representing the number of asterisks in each row. The result is a square pattern with n rows and n columns of asterisks.

You can adjust the value of n to create square patterns of different sizes.

 

Disclaimer:-

Under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational, or personal use tips the balance in favor of fair use.

 

6. Loops

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?