patternprogram_133 softethics

Pattern 133 (Reverse Pyramid I)

C

#include <stdio.h>

int main()
{
  int i,j,k;

  int p_height=5;

  for(i=p_height; i>=1; i--)
  {
    for(k=p_height-1; k>=i; k--)
    {
      printf(" ");
    }
    for(j=i; j>=1; j--)
    {
      printf("* "); // space after '*'
    }
    printf("\n");
  }
  return 0;
}

/*-- Another Logic using if-else --*/

#include <stdio.h>


int main()
{
  int n=5;//size
  int i,j;



  for(i=n; i>=1; i--)
  {
    for(j=n; j>=1; j--)
    {
      if(i>=j)
        printf("* "); // space after '*'
      else
        printf(" ");
    }
    printf("\n");
  }
  return 0;
}

/*--------------------------------*/

C++

Java

C#

Python

Tutorial (YouTube)

5 1 vote
Rate this Program
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
mohita

Awesome….