In: Computer Science
Solution:
I have only used loops and if conditions to print the pattern
Code:
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter an odd number: ";
cin>>n;
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==n/2+1 && j==n/2+1)
{
cout<<"*";
}
if(j<n/2+1 && (j == i || j == (n + 1 - i)))
{
cout<<"+";
}
if(j>n/2+1 && (j == i || j == (n + 1 - i)))
{
cout<<"x";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
}
Screenshot of Output and Code: