Pattern Printing - c - Spicy Coders

Recent

Monday, July 10, 2017

Pattern Printing - c

Example Input 1: 
6

Output: 
******
b*****
bb****
bbb***
bbbb**
bbbbb*

Example Input:
8

Output: 
********
b*******
bb******
bbb*****
bbbb****
bbbbb***
bbbbbb**
bbbbbbb*

Coding:

#include <stdio.h>
 int main() 
{
          int n,i,j;
          scanf("%d",&n);
          for(i=n;i>=1;i--)
{
          for(j=0;j<n-i;j++)
          {
          printf("b");
          }
          for(j=1;j<=i;j++)
         {
          printf("*");
          }
          printf("\n");
}
          return 0;

}

No comments:

Post a Comment