Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: asterisk pattern

by BrowserUk (Pope)
on Oct 27, 2011 at 11:23 UTC ( #934117=note: print w/replies, xml ) Need Help??

in reply to asterisk pattern

sub la{ my $n = shift; print ' ' x ( $n - $_ ), '*' x $_ for 1 .. $n, reverse 0 .. $n - 1; };; la(3);; * ** *** ** * la(6);; * ** *** **** ***** ****** ***** **** *** ** *

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: asterisk pattern
by Monk_perl on Oct 27, 2011 at 11:33 UTC
    #include<stdio.h> #include<conio.h> main() { int n,r=1,val,j; clrscr(); printf("enter the number of rows in the pyramid\t"); scanf("%d",&n); while(r<=n) { val=r; for(j=1;j<=n-r;j++) printf("\t"); for(j=1;j<=2*r-1;j++) if(j<=(2*r-1)/2) printf("%d\t",val++); else if(j==(2*r-1)/2+1) printf("%d\t",val); else printf("%d\t",--val); printf("\n"); r++; } getch(); }

      This site is about Perl programming, not C programming unless in close relation to Perl. If you want to translate your code to Perl, you will find that the code is a valid Perl program with very little modifications.

      From Wikipedia

      conio.h is a C header file used in old MS-DOS compilers to create text user interfaces. It is not described in The C Programming Language book, and it is not part of the C standard library, ISO C nor is it required by POSIX.

      Not only is your code not Perl, it is even totally obsolete C, written for MS-DOS.

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
      Here's the how to embed perl in your C program tutorial. perlembed (update: initially pulled wrong tut)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://934117]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2017-03-29 22:57 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (353 votes). Check out past polls.