Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: asterisk pattern

by Monk_perl
on Oct 27, 2011 at 11:33 UTC ( #934119=note: print w/replies, xml ) Need Help??

in reply to Re: asterisk pattern
in thread asterisk pattern

#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(); }

Replies are listed 'Best First'.
Re^3: asterisk pattern
by Corion (Pope) on Oct 27, 2011 at 11:38 UTC

    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.

Re^3: asterisk pattern
by zentara (Archbishop) on Oct 27, 2011 at 11:49 UTC
    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
Re^3: asterisk pattern
by rgiskard (Hermit) on Oct 28, 2011 at 04:59 UTC
    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://934119]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2017-05-28 03:29 GMT
Find Nodes?
    Voting Booth?