I tried to solve this question but I am not able to do

I am unable to print the stars correctly.

int main()

{

int n;
int k=0;
cin>>n;

for(int i=n;i>=0;i--){
    for(int j=1;j<=i;j++){
        cout<<j<<" ";
    }

    cout<<endl;

    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<n-i;++j){
            cout<<" ";
        }
        while(k!=2*i-1){
            cout<<"*";
            ++k;
        }
        cout<<endl;
    }


return 0;

}

ok you can refer to this code now @rajharsh865
https://ide.codingblocks.com/s/23176
dont forget to mark resolved and hit like if cleared :smiley: