Pattern numbers & stars - 1

#include
using namespace std;
int main()
{
int n,i,j,nst=1;
cin>>n;
for(i=n; i>=1; i–)
{
for(j=1; j<=i; j++)
{
cout<<j;
}
if (i!=n)
{
for(j=1; j<=nst; j++)
{
cout<<"*";
}
nst=nst+2;
}
cout<<endl;
}
return 0;
}

i am only able to pass given test case

1 Like

@chaman9,
Please make sure you share cb.lk/ide link of your code when you ask doubt. It would be very helpful for us.

Btw, your code is correct, just make sure you print all characters (numbers or stars) followed by a space, i.e

cout<<j<<" ";
and
cout<<"* ";

Thank you, i got the output.
i am not getting how you are asking to share my code
how do i share the link of my code?

@chaman9,

  • Go to Coding Blocks IDE
  • Paste your code there, with any doubtful test case in input section (if you have one)
  • Hit save. This will generate a unique link in address bar of your browser.
  • Now you can share this link with us or your friends, and everyone can see your beautifully indented code from anywhere.

thank you… i got my doubt cleared now!!