Hi there I am new to c++ and i need your help please. here is my pattern:
*********
*******
*****
***
*
***
*****
*******
*********
I tried writing code for this, but it does not give the desired result. Can anyone help me please? here is my code:
#include<bits/stdc++.h>;
using namespace std;
int main()
{
int n=5,j,k;
bool o=false,t=false;
for(int i=((2*n) - 1); i >= -((2*n)-1); i -=2)
{
for(j=10-abs(i); j >0;j-=2)
{
cout << " ";
}
for(k=abs(i);k>0;k--)
{
cout << "*";
}
cout << endl;
}
return 0;
}
my output is:
*********
*******
*****
***
*
*
***
*****
*******
*********
Note: there are two lines with one *
whereas the desired output has only one line with one *
.