Example
Input :
Enter N : 5
Output :
* * * * * * * * * * * * * * * * *
Required Knowledge
Basic C++ programming, if-else, for loop, nested loop
Program to print X star pattern
/** C++ program to print X star pattern series */ #include <iostream>using namespace std; int main() { int i, j, N; int count; cout<<"Enter N: "; cin>>N; count = N * 2 - 1; for(i=1; i<=count; i++) { for(j=1; j<=count; j++) { if(j==i || (j==count - i + 1)) { cout<<"*"; } else { cout<<" "; } } cout<<"\n"; } return 0; }