Pattern 21

Pattern 21
  • C Code
  • C++ Code
  • Java Code
  • Get these codes on your Android Device

C Code


        1
      2 2 2
    3 3 3 3 3
  4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 
#include<stdio.h> #include<conio.h> void main() { int min_s=1; int p_height=5; //change value to increase or decrease the size of piramid int p_space=p_height-1; int i,j,k; clrscr(); for(i=1;i<=p_height;i++){ for(j=p_space;j>i;j--) { printf(" "); } for(k=0;k<min_s;k++) { printf("%d",i); } min_s+=2; printf("\n"); } getch(); }

C++ Code


        1
      2 2 2
    3 3 3 3 3
  4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 
#include<iostream.h> #include<conio.h> void main() { int n=5; //size int z=1; clrscr(); for(int i=0;i<n;i++){ for(int j=n-1;j>i;j--) { cout<<" "; } for(int k=0;k<z;k++) { cout<<z-i; } z+=2; cout<<endl; } getch(); }

Java Code


        1
      2 2 2
    3 3 3 3 3
  4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 
class Pattern_21 { public static void main(String args[]) { int n=5; //size int z=1; for(int i=0;i<n;i++){ for(int j=n-1;j>i;j--) { System.out.print(" "); } for(int k=0;k<z;k++) { System.out.print(z-i); } z+=2; System.out.println(); } } //end of main } //end of class

Android Apps


Get pattern printing codes on your Android Device :

# C Pattern Programs Free App
# C++ Pattern Programs Free App
# Java Pattern Programs Free App


Get Them Now !!!

Download Code           More Patterns !!!