Skip to content

Instantly share code, notes, and snippets.

@voldyman
Created October 30, 2014 17:04
Show Gist options
  • Save voldyman/4aaac237407eae1c92aa to your computer and use it in GitHub Desktop.
Save voldyman/4aaac237407eae1c92aa to your computer and use it in GitHub Desktop.
print stars with spacing
#include<stdio.h>
void print_char(char c, int num)
{
if (num <= 0)
return;
printf("%c", c);
print_char(c, --num);
}
void print_char_rows_with_index(char c, int start, int end)
{
if (start >= end)
return;
int spacing = end - start;
print_char(' ', spacing);
print_char(c, start);
printf("\n");
print_char_rows_with_index(c, ++start, end);
}
void print_char_rows(char c, int num)
{
print_char_rows_with_index(c, 1, num);
}
int main(void)
{
print_char_rows('*', 7);
}
@voldyman
Copy link
Author

  *
 **
***



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment