patternprogram_203 softethics

Pattern 203

C

#include<stdio.h>

int main()
{
  int i,j;

  for (i=0; i<=3; i++)
  {
    for (j=1; j<=4; j++)
    {
      if (j<=i)
        printf("0");
      else
        printf("%d",i+j);
    }
    printf("\n");
  }
  return 0;
}

C++

#include<iostream.h>

int main()
{
    int i,j;

    for (i=0; i<=3; i++)
    {
        for (j=1; j<=4; j++)
        {
            if (j<=i)
                cout<<"0";
            else
                cout<<i+j;
        }
        cout<<endl;
    }
    return 0;
}

Java

class PatternProg
{
    public static void main(String args[])
    {
        for (int i = 0; i <= 3; i++)
        {
            for (int j = 1; j <= 4; j++)
            {
                if (j <= i)
                {
                    System.out.print("0");
                }
                else
                {
                    System.out.print(i + j);
                }
            }
            System.out.println();
        }

    }
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    for (int i = 0; i <= 3; i++)
    {
      for (int j = 1; j <= 4; j++)
      {
        if (j <= i)
        {
          Console.Write("0");
        }
        else
        {
          Console.Write(i + j);
        }
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

for x in range(0, 4):
    for y in range(1, 5):
      if y <= x:
        print("0", end="")
      else:
        print(x + y, end="")
    print()
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments