Advertisement
Guest User

triangle

a guest
Nov 27th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void prchar (char c, int n)
  5. {
  6.     for (int i=0; i<n; i++)
  7.         printf("%c",c);
  8. }
  9.  
  10. void tri(int h)
  11. {
  12.     if (h==1)
  13.     {
  14.         prchar('*', 1);
  15.         printf("\n");
  16.     }
  17.     else
  18.     {
  19.         prchar('*', h);
  20.         printf("\n");
  21.         tri(h-1);
  22.     }
  23. }
  24.  
  25. int main()
  26. {
  27.     int h;
  28.     printf("Enter the integer: ");
  29.     scanf("%d",&h);
  30.     printf("\n");
  31.     tri(h);
  32.    
  33.     printf("\n\n\n");
  34.    
  35.     system("pause");
  36.     return 1;  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement