Skip to content

Instantly share code, notes, and snippets.

@arandilopez
Created February 17, 2014 23:54
Show Gist options
  • Save arandilopez/9061742 to your computer and use it in GitHub Desktop.
Save arandilopez/9061742 to your computer and use it in GitHub Desktop.
How to build an triangle with C
#include <stdio.h>
int main()
{
int i,space,rows,k=0;
printf("Enter the number of rows: ");
scanf("%d",&rows);
for(i=1;i<=rows;++i)
{
for(space=1;space<=rows-i;++space)
{
printf(" ");
}
while(k!=2*i-1)
{
printf("*");
++k;
}
k=0;
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment