Write a program to generate the following pattern Character Pattern 7.
bbbb*bbbb
bbb***bbb
bb***** bb
b******* b
*********
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 :
bbbb*bbbb
bbb***bbb
bb***** bb
b******* b
*********
Solution
import java.io.*;
import java.util.*;
class Main
{
public
static void main(String ar[])
{
Scanner sc = new Scanner(System.in);
int n, i, j, k, l;
n = sc.nextInt();
for (i = 1; i <= n; i++)
{
for (j = i; j < n; j++)
{
System.out.print("b");
}
for (k = 2; k < 2*i + 1; k = k +1)
{
System.out.print("*");
}
for (l = i; l < n; l++)
{
System.out.print("b");
}
System.out.print("\n");
}
}
}#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=i;j<n;j++)
{
cout<<"b";
}
for(int k=2;k<2*i+1;k++)
{
cout<<"*";
}
for(int l=i;l<n;l++)
{
cout<<"b";
}
cout<<endl;
}
return 0;
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Character Pattern 7 with Java, C++ [Solved] Character Pattern 7 with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Character-Pattern-7-with-Java-C.png)
![[Solved] Enrolling the Events with C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Enrolling-the-Events-with-C-300x200.png)
![[Solved] Addition Challenge with Java, C++, Python](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Addition-Challenge-with-Java-C-Python-300x200.png)
![[Solved] Auditions with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Auditions-with-Java-C-300x200.png)