Pattern magic test case failed

#include
using namespace std;
int main() {
int n, i, j;
cin>>n;
for(i = 1 ; i <= n ; i++){
for(j =i ; j <= n ; j++){
cout<<’’;
}
for(j = 1 ; j <= 2
i-2 ; j++){
cout<<" “;
}
for(j = i ; j <= n ; j++){
cout<<’’;
}
cout<<endl;
}
for(i =1 ; i <= n ; i++){
for(j=1 ; j <= i ; j++){
cout<<’
’;
}
for(j=2i-2 ; j<2n-2 ; j++){
cout<<” ";
}
for(j=1 ; j <= i ; j++){
cout<<’*’;
}
cout<<endl;
}
return 0;
}

I am not able to pass the test case, but I think code is perfect. can somebody tell me why?

hi @mudasir.mushtaq2021,
in middle you r printing same row 2 times
to avoid that in first for loop go till i<n not i<=n
also first row for n=5 has 9 stars but you r having 10

1 Like

I am still not getting the correct output

hi @mudasir.mushtaq2021,
check here https://ide.codingblocks.com/s/660987 (few adjustments according to what you wrote)

It still shows runguard error

@mudasir.mushtaq2021, please check properly

@mudasir.mushtaq2021, see how you copy pasted

do it properly

Thanks it is running OK now

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.