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
Post a Comment