Random Triangle
deleted
Last edited on
Any assistance will be much appreciated.
use nested if, hope it can help you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <stdio.h>
void clear()
{
for(int a=0;a<25;a++) printf("\n");
}
int main ()
{
int i,a,n,b;
printf("insert a number = ");
scanf("%d",&n);fflush(stdin);
//print to bottom
for (i=1;i<=n;i++)
{
//print empty triangle
for(a=n-i;a>=1;a--)
{
printf(" ");
}
//print triangle
for(b=1;b<=i;b++)
{
printf("*");
}
clear();
printf("\n");
}
getchar();
}
|
Topic archived. No new replies allowed.