print different pattern using c language.

Hello Friend’s

Today we learn how to print different pattern using c language , we are print different pattern using ‘loop’ and mathematical logic of row and column .

In this program we use 'for' loop or nested ‘for’ loop and ‘relational operaters’

First we know the structure then write a program for that

Let’s started…

STRUCTURE:- Half pyramid

 *
 * *
 * * *
 * * * *
 * * * * *
 * * * * * *
 * * * * * * * 

SOURCE CODE:-


#include<stdio.h>
int main(){
    int  no_row,row,column;
    printf("Enter the number of Row:");
    scanf("%d",&no_row);
    for(row=0;row<=no_row;row++){
        for(column=0;column<row;column++){
            printf("* ");
        }
        printf("\n");
    }
return 0;

}

STRUCTURE:- Inverted half pyramid of alphabet

A A A A A B B B B C C C D D E

SOURCE CODE:-


#include<stdio.h>
int main(){
    int  no_row,row,column;
     char ch='A';
    printf("Enter the number of Row:");
    scanf("%d",&no_row);
    for(row=no_row;row>=0;row--){
        for(column=0;column<row;column++){
            printf("%c ",ch);
        }
         ch++;
        printf("\n");
    }
    
return 0;

}

STRUCTURE:- Full pyramid

      *
     ***
    *****
   *******
  *********
 ***********
*************

SOURCE CODE:-


#include<stdio.h>
int main(){
    int t,r,s,p;
     // t stand for total number of row
     // r stand for  row
     // s stand for space
     // p stand for print '*'
     
    printf("enter the number of row:");
    scanf("%d",&t);
    for(r=0;r<=t;r++){
        for(s=0;s<(t-r);s++){
            printf(" ");
        }
        for(p=0;p<((2*r)-1);p++){
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

STRUCTURE:- Diamond

  
      *
     ***
    *****
   *******
  *********
 ***********
*************
 ***********
  *********
   *******
    *****
     ***
      *

SOURCE CODE:-


#include<stdio.h>
int main(){
    int n,i,j,k;
     // n stand for total number of row
     // i stand for  row
     // j stand for space
     // k stand for print '*'
     
    printf("enter the no of row\n");
    scanf("%d",&n);

    for(i=0;i<=n;i++){
        for(j=0;j<(n-i);j++){
            printf(" ");
        }
        for(k=0;k<((2*i)-1);k++){
            printf("*");
        }
        printf("\n");
    }
        for(i=n-1;i>=0;i--){
        for(j=0;j<(n-i);j++){
            printf(" ");
        }
        for(k=0;k<((2*i)-1);k++){
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

STRUCTURE:- Arrow of alphabet

 A  
 B  C
 D  E  F
 G  H  I  J
 K  L  M  N  O
 P  Q  R  S
 T  U  V
 W  X
 Y

SOURCE CODE:-


#include<stdio.h>
int main(){
    int i,j;
    char ch='A';
    for(i=0;i<5;i++){
        for(j=0;j<i;j++){
       printf("%c  ",ch);
        ch++;
        }
        printf("\n");
        
         
    }

       for(i=5;i>=0;i--){
        for(j=0;j<i;j++){
        printf("%c  ",ch);
         ch++;
        }
        printf("\n");
       
    } 
    return 0;
}

                                              

                                                      Thank-you guys

4 Comments

  1. I read that Post and got it fine and informative. sa game

    ReplyDelete
  2. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. สล็อตpg เว็บตรง

    ReplyDelete
  3. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: รีวิวคาสิโนยูฟ่าเบท

    ReplyDelete
  4. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. ufa88s.info

    ReplyDelete