Thursday 7 April 2016

Color-Tringle-c-clanguage-program

Color Triangle C Language Program with full code.This program creates a dynamic triangle based on user input and print message when  tringle size exceeded.

Color C Language Program outpur screen

#include<stdio.h>
#include<conio.h>
/* Girfa : Student Help
   Color triangle example
   for program visit :
   http://girfahelp.blogspot.in/p/c-language.html
*/
void main()
{

int a,b,c,d=1,space=20;
clrscr();
printf("Enter size of triangle>> ");
scanf("%d",&c);
if(c<=11)
{
a=1;
while(a<=c)
{
b=1;
while(b<=space)
{
printf(" ");
b++;
}
b=1;

while(b<=d)
{
textcolor(b);
cprintf("*");
b++;
}
printf("\n");
a++;
d=d+2;
space--;

}
a=0;
while(a<=c)
{
b=1;
while(b<=space)
{
printf(" ");
b++;
}
b=1;

while(b<=d)
{
textcolor(b);
cprintf("*");
b++;
}
printf("\n");
a++;
d=d-2;
space++;

}
}
else
{
printf("Out of Range");
}
getch();
}

More Program

No comments:

Post a Comment