Hello friends hm ap is post me a word ka pattern draw krenge program bana kr. So if you want then please like our post. Or if you want to contact us, So go to our about Us section.
Draw.java
------------------------------------------------------
Explanation:
1. We start by creating a Java class named `DrawA`.
2. In the `main` method, we define an integer variable `n`, which determines the size of the "A" pattern. You can change this value to adjust the size of the pattern.
3. The outer `for` loop, with the variable `i`, controls the number of rows in the pattern. It iterates from 1 to `n`.
4. Within each row, we have a series of nested loops and print statements to create the "A" shape. Here's what happens within each row:
- We use the first inner `for` loop (with variable `j`) to print spaces before the first asterisk. The number of spaces decreases as we move down the rows.
- We then print the first asterisk.
- The second inner `for` loop is used to print spaces between the two asterisks. The number of spaces between the asterisks is determined by `(2 * i - 2)`. For the top row, there are no spaces between the asterisks (i = 1), but as we move down, the number of spaces increases.
- We print the second asterisk if it's not the first row (i != 1). This completes the top part of the "A."
5. After the top part of the "A" is printed, we move to the next line using `System.out.println()`.
6. To print the base of the "A," we use another `for` loop to add spaces at the beginning, aligning it with the top part of the "A." Then, we print a single asterisk to form the base.
7. Finally, we use `System.out.println()` again to move to the next line, completing the "A" pattern.
By running this Java program, you'll get an "A" pattern made of asterisks on the console. You can adjust the value of `n` to change the size of the "A" as desired.