recent posts

Pyramid, Star Series and Patterns Programs in C language | C programming


Hi, I'm Golam Rabbani. Today I will discuss
about Pyramid, Star Series and Patterns Programs.
Greetings! How are you all? Hope everyone is well.
At first we have to know that what is Pyramid,
Star Series and Patterns Programs?
Just it grow your skill for handling loop.
How to control your loop, that’s it.
Let’s go……
@Program 1:
#include<stdio.h>
int main(){
    int i,j,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j<=i; j=j+1){
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
   1
   11
   111
   1111
   11111
*/
Output:

@Program 2:
#include<stdio.h>
int main(){
    int i,j,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j<=n-i; j=j+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
     111111
     11111
     1111
     111
     11
     1
*/
Output:

@Program 3:
#include<stdio.h>
int main(){
    int i,j,k,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j<=i; j=j+1){
            printf(" ");
        }
        for(k=0; k<=n-i; k=k+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
     11111
      1111
       111
        11
         1
*/
Output:

@Program 4:
#include<stdio.h>
int main(){
    int i,j,k,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j<=n-i; j=j+1){
            printf(" ");
        }
        for(k=0; k<=i; k=k+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
     1
    11
   111
  1111
*/
Output:

@Program 5:
#include<stdio.h>
int main(){
    int i,j,k,l,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j< n-i; j=j+1){
            printf(" ");
        }
        for(k=0; k< i; k=k+1){
            printf("1");
        }
        for(l=0; l<=i; l=l+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
     1
    111
   11111
  1111111
*/
Output:

@Program 6:
#include<stdio.h>
int main(){
    int i,j,k,l,n;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j< i; j=j+1){
            printf(" ");
        }
        for(k=0; k< n-i; k=k+1){
            printf("1");
        }
        for(l=0; l<= n-i; l=l+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
  1111111
   11111
    111
     1
*/
Output:

@Program 7:
#include<stdio.h>
int main(){
    int i,j,k,l,n,m,o,p;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j< n-i; j=j+1){
            printf(" ");
        }
        for(k=0; k< i; k=k+1){
            printf("1");
        }
        for(l=0; l<=i; l=l+1){
            printf("1");
        }
        printf("\n");
    }

    for(i=0; i<=n; i=i+1){
        for(m=0; m< i; m=m+1){
            printf(" ");
        }
        for(o=0; o< n-i; o=o+1){
            printf("1");
        }
        for(p=0; p<=n-i; p=p+1){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}

/*
Output:
     1
    111
   11111
  1111111
  1111111
   11111
    111
     1
*/
Output:

@Program 8:
#include<stdio.h>
int main(){
    int i,j,k,l,n,m,o,p,a;
    printf("Enter number: ");
    scanf("%d", &n);
    for(i=0; i<=n; i=i+1){
        for(j=0; j< n-i; j=j+1){
            printf(" ");
        }
        for(k=0; k< i; k=k+1){
            printf("1");
        }
        for(l=0; l<=i; l=l+1){
            printf("1");
        }
        for(k=0; k< n-i; k=k+1){
            printf(" ");
        }
        for(l=0; l<=n-i; l=l+1){
            printf(" ");
        }
        for(k=0; k< i-3; k=k+1){
            printf("1");
        }
        for(l=0; l<=i-3; l=l+1){
            printf("1");
        }
        printf("\n");
    }

    for(i=0; i<=n/2; i=i+1){
        for(m=0; m<=n-m; m=m+1){
            printf(" ");
        }
        for(o=0; o<=n; o++){
            printf("1");
        }
        for(p=0; p<=l; p++){
            printf(" ");
        }
        for(p=0; p< l; p++){
            printf("1");
        }
        printf("\n");
    }
    for(i=0; i<=n; i=i+1){
        for(a=0; a<=n; a++){
            printf("1");
        }
        for(a=0; a<=n; a++){
            printf("1");
        }
        for(a=0; a<=n; a++){
            printf("1");
        }
        for(a=0; a<=n-4; a++){
            printf("1");
        }
        printf("\n");
    }
    return 0;
}
/*
Output:
     1
    111
   11111
  1111111     1
 111111111   111
11111111111 11111
   111111    111
   111111    111
   111111    111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
*/
Output:
Other type, try home.Thank you.
Pyramid, Star Series and Patterns Programs in C language | C programming Pyramid, Star Series and Patterns Programs in C language | C programming Reviewed by Golam Rabbani on November 27, 2018 Rating: 5

No comments:

top navigation

Powered by Blogger.