Character Pattern 8: Write a program to generate the following pattern.
*********
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
#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 C++ [Solved] Character Pattern 8 with C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Character-Pattern-8-with-C.png)
![[Solved] The Latest Time to Catch a Bus LeetCode Contest](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-The-Latest-Time-to-Catch-a-Bus-LeetCode-Contest-300x200.png)
![[Solved] Average of String Contest Problem](https://realcoder.techss24.com/wp-content/uploads/2022/06/Solved-Average-of-String-Contest-Problem-300x200.png)
![[Solved] Maximum of 3 numbers with C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Maximum-of-3-numbers-with-C-300x200.png)