Pattern Magic While Compilation Working good After submit shoing wrong answer

While Compilation code work perfet after submit shoing wrong answer
#include
using namespace std;
int main(){
int n;
cin>>n;
// Upper HALF
for(int i=0;i<n;i++){
// first print n-i stars
for(int j=0;j<n-i;j++)
cout<<"* ";

    // Print 2*i-1 spaces
    for(int j=0;j<(2*i-1);j++)
        cout<<"  ";

    // Again Print n-i stars 
    // but there is one less star in first row
    int no_of_stars = n-i;
    if(i==0)
        no_of_stars--;

    for(int j=0;j<no_of_stars;j++)
        cout<<"* ";

    cout<<endl;
}


// Lower HALF
for(int i=n-2;i>=0;i--){
    // first print n-i stars
    for(int j=0;j<n-i;j++)
        cout<<"* ";

    // Print 2*i-1 spaces
    for(int j=0;j<(2*i-1);j++)
        cout<<"  ";

    // Again Print n-i stars 
    // but there is one less star in first row
    int no_of_stars = n-i;
    if(i==0)
        no_of_stars--;

    for(int j=0;j<no_of_stars;j++)
        cout<<"* ";

    cout<<endl;
}
return 0;

}

hi @dheerajjha11111_bb855e8d7a52ef0d,

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.