Pattern 43

Pattern 43 post thumbnail image

C

#include <stdio.h>
int main()
{
  int i,j,t;

  for (i=1; i<=5; i++)
  {
    t=i-1;
    for (j=1; j<=i; j++)
    {
      printf("%d ",t+i);
      t+=2;
    }
    printf("\n");
  }
  return 0;
}

C++

#include<iostream.h>
int main()
{
    int i,j,t;

    for (i=1; i<=5; i++)
    {
        t=i-1;
        for (j=1; j<=i; j++)
        {
            cout<<t+i<<" ";
            t+=2;
        }
        cout<<endl;
    }
    return 0;
}

Java

    class PatternProg
    {
    public static void main(String args[])
    {
        for (int i = 1; i <= 5; i++)
        {
            int t = i - 1;
            for (int j = 1; j <= i; j++)
            {
                System.out.print((t+i)+" ");
                t += 2;
            }
            System.out.println();
        }
    }
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    for (int i = 1; i <= 5; i++)
    {
      int t = i - 1;
      for (int j = 1; j <= i; j++)
      {
        Console.Write((t + i) + " ");
        t += 2;
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

for x in range(1, 6):
  t = x - 1
  for y in range(1, x+1):
    print(t + x, end=" ")
    t += 2
  print()
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Related Patterns