Example
Input :
Enter n : 5
Output :
+ + + + +++++++++++++++++++ + + + +
Required knowledge
Basic C++ programming, if-else, for loop, nested loop
Program to print plus star pattern series
/** C++ program to print the plus star pattern series */ #include<iostream> using namespace std; int main() { int i, j, N; cout<<"Enter N: "; cin>>N; // Run an outer loop from 1 to N*2-1 for(i=1; i<=(N * 2 - 1); i++) { // For the center horizontal plus if(i == N) { for(j=1; j<=(N * 2 - 1); j++) { cout<<"+"; } } else { // For spaces before single plus sign for(j=1; j<=N-1; j++) { cout<<" "; } cout<<"+"; } cout<<"\n"; } return 0; }