Pattern 20

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

C Code


        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * * 
#include<stdio.h> #include<conio.h> void main() { int min_stars=1; /*change value to set min. no. of stars in piramid take odd no. for odd no. of stars in each row 1-3-5 etc take even no. for even no. stars in each row, 2-4-6 etc */ 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=0;i<p_height;i++){ for(j=p_space;j>i;j--) { printf(" "); } for(k=0;k<min_stars;k++) { printf("*"); } min_stars+=2; printf("\n"); } getch(); }

C++ Code


        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * * 
#include<iostream.h> #include<conio.h> void main() { int min_stars=1; /*change value to set min. no. of stars in piramid take odd no. for odd no. of stars in each row 1-3-5 etc take even no. for even no. stars in each row, 2-4-6 etc */ 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=0;i<p_height;i++){ for(j=p_space;j>i;j--) { cout<<" "; } for(k=0;k<min_stars;k++) { cout<<"*"; } min_stars+=2; cout<<endl; } getch(); }

Java Code


        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * * 
class Pattern_20 { public static void main(String args[]) { int min_stars=1; /*change value to set min. no. of stars in piramid take odd no. for odd no. of stars in each row 1-3-5 etc take even no. for even no. stars in each row, 2-4-6 etc */ int p_height=5; //change value to increase // or decrease the size of piramid int p_space=p_height-1; for(int i=0;i<p_height;i++){ for(int j=p_space;j>i;j--) { System.out.print(" "); } for(int k=0;k<min_stars;k++) { System.out.print("*"); } min_stars+=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 !!!