Canna

Monday, 24 September 2018

Star formation

  • Problem Description

    program to print the half pyramid using star
  • Test Case 1

    Input (stdin)
    5
    
    
    Expected Output
    *
    
    **
    
    ***
    
    ****
    
    *****
  • Test Case 2

    Input (stdin)
    3
    
    
    Expected Output
    *
    
    **
    
    ***
  • Program
  • #include <stdio.h>
    int main()
    {
     int n,i,j;
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
        for(j=0;j<i;j++)
          printf("*");
        printf("\n");
      }
    
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.