Thursday, 11 September 2014

Pyramid Structure in C Language program using patterns code with Example

Pyramid structure in C source code: This program provides you a pyramid formatted output for a given input. This can be a simple code to understand easily. It generates the pyramid shape by using patterns. It is totally based on your “n” number of input. An example program is given below.

Create pyramid structure program in C is used to create the shape of pyramid by given input values. It is using many looping statements and blank spaces to create a pyramid structure exactly.

Pyramid program:

Q: Write a C program to create a pyramid structure using patterns.

//Header files
void main()
    //Program variables
    int j,i,l,nm,blanks,un;
    printf("Enter n value : ");//Display function
    scanf("%d",&un);//Getting input function
    for(i=1,l=1;i<=un;i++)//Looping statement
    {for(blanks=n-1;blanks>=l;blanks--) //Nested loop
        printf(" ");
    {   printf("%d ",nm);
        if(j>=((l+1)/2))//Conditional statement
        else    nm++;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.