08 January 2022

Pattern Program with Color Code Blinking and Delay

#include<stdio.h>

#include<conio.h>


void main()

{

int i, j, no;

clrscr();


textcolor(4+128);

cprintf("Enter number: ");

scanf("%d", &no);


for(i=1; i<=no; i++)

{

for(j=1; j<=no-i; j++)

{

printf(" ");

delay(70);

}

for(j=1; j<=i; j++)

{

textcolor(j);

cprintf("*");

delay(70);

}

for(j=i-1; j>=1; j--)

{

textcolor(j);

cprintf("*");

delay(70);

}

printf("\n");

}


for(i=1; i<=no-1; i++)

{

for(j=1; j<=i; j++)

{

printf(" ");

delay(70);

}

for(j=1; j<=no-i; j++)

{

textcolor(j);

cprintf("*");

delay(70);

}

for(j=no-i-1; j>=1; j--)

{

textcolor(j);

cprintf("*");

delay(70);

}

printf("\n");

}

getch();

}


/*


Output:


Enter number: 5

     *

   ***

  *****

 *******

*********

 *******

  *****

   ***

     *


*/






No comments:

Post a Comment