my code
https://ide.codingblocks.com/s/42278
question link
https://online.codingblocks.com/player/11915/content/5025?s=1493
what’s the problem with my code
Ganesha pattern
you are using cout<<"\t";
instead of this use cout<<" ";
1 Like
#include
using namespace std;
int main()
{
int k,n,i,j;
cin>>n;
for(k=1;k<=1;k++)
{
cout<<"";
for(i=1;i<(n/2);i++)
{
cout<<" “;
}
for(j=1;j<=(n/2)+1;j++)
{
cout<<”";
}
cout<<endl;
}
for(k=2;k<=(n/2);k++)
{ //cout<<k<<" “;
cout<<”";
for(i=1;i<(n/2);i++)
{
cout<<" “;
}
cout<<”";
cout<<endl;
}
for(k=(n/2)+1;k<=((n/2)+1);k++)
{
for(i=1;i<=n;i++)
{
cout<<"";
}
cout<<endl;
}
for(k=((n/2)+2);k<=(n-1);k++)
{
for(i=1;i<=(n/2);i++)
{
cout<<" “;
}
cout<<”";
for(j=1;j<(n/2);j++)
{
cout<<" “;
}
cout<<”";
cout<<endl;
}
for(k=n;k<=n;k++)
{
for(i=1;i<=(n/2)+1;i++)
{
cout<<"";
}
for(j=(n/2)+2;j<n;j++)
{
cout<<" “;
}
cout<<”*";
cout<<endl;
}
return 0;
}
Check difference
Hit like if u get your mistakes
1 Like