Skip to main content

Colored Pyramid pattern using * in C Language


 
Note : cprintf() and textcolor() functions use conio.h library
·         textcolor () : colors the text
·         cprintf() : print the text in color
·         cprintf() : \n \t etc will not work as they work in printf()

#include<stdio.h>
#include<conio.h>

void main()

{
                int i,j,length;
                clrscr();

                printf("Enter Length : ");
                scanf("%d",&length);
                for(j = 0; j < (length * 2) +2;j++) // Header Line Based on length and 2 extra because of | this symbol
                {
                                textcolor(4);
                                cprintf("-");
                }
                printf("\n");
                for(j=0;j<length; j++)
                {
                                textcolor(4);
                                cprintf("|"); //For Left side | symbol
                                for(i=length-j; i>1; i--) //For left side blank spaces
                                {
                                                printf(" ");
                                }
                                for(i=0; i<=j; i++)
                                {
                                                textcolor(i+2);
                                                cprintf("* ");
                                }
                                for(i=length-j; i>1; i--)//For Right side blank spaces
                                {
                                                printf(" ");
                                }
                                textcolor(4);
                                cprintf("|"); // For the Right side | symbol and than new line
                                printf("\n");
                }
                for(j = 0; j < (length * 2) + 2;j++)// Bottom Line Based on length and 2 extra because of | this symbol
                {
                                textcolor(4);
                                cprintf("-");
                }
                getch();
}

//Prepared by Sama Adil : instagram @adilsama28
//If you want to learn C, Advanced C , C++ or more Contact : +91 9724 605358

Comments

Popular posts from this blog

Gujarati Keyboard layout (terafont-varun), Computer Short cut key, Tally short cut key

Word , Excel , Power Point Shortcut Key in Gujarati

Terafont-Varun (Gujarati Typing) Keyboard Layout by "Sama Soyab"

  For Gujarati Typing : Required : Terafont-Varun Font  After Successfully Installed Terafont Varun Open Any Text Editor or any program. Select Font Terafont-Varun -> Ok For more detail please watch below video. Search Topics : Learn terafont varun, Learn terafont chandan, Learn terafont gujarati to english translation, Learn terafont varun keyboard, Learn terafont converter, Learn terafont varun zip, Learn terafont keyboard, Learn terafont kinnari, Learn terafont akash, Learn terafont aakash, Learn terafont akash ttf, Learn terafont aakash gujarati download, Learn terafont akash keyboard, Learn terafont akash download for windows 10, Learn terafont akash font download, Learn terafont arun, Learn terafont border, Learn terafont chandan keyboard, Learn terafont-chandan font, Learn tera font chandana, Learn convert terafont to shruti, Learn convert terafont varun to shruti, Learn terafont varun chart, Learn terafont download, Learn terafont download for windows 10, Learn tera...