patternprogram_44 softethics

Pattern 44

C

#include<stdio.h>


int main()
{
  int i,j,k=0;
  int n=4; // size

  for(i=1; i<=n; i++)
  {
    k+=i;
    for(j=k; j>k-i; j--)
    {
      printf("%d",j);
    }
    printf("\n");
  }

}

C++

 #include<iostream.h>
 
 
 int main()
 {
 int i,j,k=0;
 int n=4; // size
 
 for(int i =1;i<=n;i++)
 {
  k+=i;
  for(int j =k;j>k-i;j--)
  {
   cout<<j;
  }
  cout<<"\n";
 }
 
 }

Java

     public class PatternProg
     {
     public static void main(String args[])
     {
     int i;
     int j;
     int k = 0;
     int n = 4; // size
 
     for (i = 1;i <= n;i++)
     {
      k += i;
      for ( j = k;j > k - i;j--)
      {
       System.out.print(j);
      }
      System.out.println();
     }
 
     }
 }

C#

using System;

public class PatternProg
{
  public static void Main()
  {
    int i;
    int j;
    int k = 0;
    int n = 4; // size

    for (i = 1; i <= n; i++)
    {
      k += i;
      for (j = k; j > k - i; j--)
      {
        Console.Write(j);
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

n = 4  # size
k = 0
for x in range(1, n + 1):
    k += x
    for y in range(k, k - x, -1):
        print(str(y) + " ", end="")
    print()
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments