Write a program to generate the following pattern Character Pattern 8.
*********
b******* b
bb***** bb
bbb***bbb
bbbb*bbbb
Input and Output Format:
Input consists of a single integer that corresponds to n, the number of rows. n is always an odd number.
Sample Input :
5
Sample Output :
*********
b******* b
bb***** bb
bbb***bbb
bbbb*bbbb
Solution
import java.io.*;
import java.util.*;
class Main
{
public
static void main(String ar[])
{
Scanner sc = new Scanner(System.in);
int i, n, j, l, k;
n = sc.nextInt();
for (i = n; i >= 1; i--)
{
for (j = n; j > i; j--)
{
System.out.print("b");
}
for (k = 2; k < 2*i + 1; k = k +1)
{
System.out.print("*");
}
for (l = n; l > i; l--)
{
System.out.print("b");
}
System.out.print("\n");
}
}
}#include <iostream>
using namespace std;
int main()
{
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
for (j = 1; j < n * 2; j++)
{
if (i >= j || j >= n * 2 - i)
printf("b");
else
printf("*");
}
printf("\n");
}
return (0);
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Character Pattern 8 with Java, C++ [Solved] Character Pattern 8 with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Character-Pattern-8-with-Java-C.png)
![[Solved] Crowd pattern with Java](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Crowd-pattern-with-Java-300x200.png)
![[Solved] Find the number of marbles in the missing bowl](https://realcoder.techss24.com/wp-content/uploads/2022/11/Solved-Find-the-number-of-marbles-in-the-missing-bowl-300x199.png)
![[Solved] Pranav and Change with Java](https://realcoder.techss24.com/wp-content/uploads/2022/10/Solved-Pranav-and-Change-with-Java-300x200.png)