patternprogram_116 softethics

Pattern 116

C

#include <stdio.h>

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

  for(i = n ; i >= 1; i--)
  {
    for(j = i; j > 1; j--)
    {
      printf(" ");
    }

    for(k = i; k <= n; k++)
    {
      printf("%c", i + 64);
    }
    printf("\n");
  }
  return 0;
}

C++

#include <iostream.h>

int main()
{
  int n = 5;
  

  for(int i = n ; i >= 1; i--)
  {
    for(int j = i; j > 1; j--)
    {
      cout<<" ";
    }
    
    for(int k = i; k <= n; k++)
    {
      cout<<(char)(i + 64);
    }
    cout<<endl;
  }
  return 0;
}

Java

class PatternProg
{
	public static void main(String args[])
	{
	  int n = 5;


	  for (int i = n ; i >= 1; i--)
	  {
		for (int j = i; j > 1; j--)
		{
		  System.out.print(" ");
		}

		for (int k = i; k <= n; k++)
		{
		  System.out.print((char)(i + 64));
		}
		System.out.println();
	  }
	  
	}
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    int n = 5;


    for (int i = n ; i >= 1; i--)
    {
      for (int j = i; j > 1; j--)
      {
        Console.Write(" ");
      }

      for (int k = i; k <= n; k++)
      {
        Console.Write((char)(i + 64));
      }
      Console.WriteLine();
    }

    Console.ReadKey(true);
  }
}

Python

n = 5

for x in range(n, 0, -1):
  for y in range(x, 0, -1):
    print(" ", end="")

  for z in range(x, n + 1):
    print(chr(x + 64), end="")

  print()
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments