Pattern 411 (String Pattern)

Pattern 411 (String Pattern) post thumbnail image

C

#include <stdio.h>
#include <string.h>

int main()
{
  char str[] = "SUMIT";
  int len = strlen(str);
  int i,j;

  for(i = 0; i < len; i++)
  {
    for(j = 1; j <= len; j++)
    {
      printf("%c ", str[len-j]);
    }
    printf("\n");
  }
  return 0;
}

C++

#include <iostream.h>
#include <string.h>

int main()
{
  char str[] = "SUMIT";
  int len = strlen(str);
  

  for(int i = 0; i < len; i++)
  {
    for(int j = 1; j <= len; j++)
    {
      cout<<str[len - j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Java

class PatternProg
{
	public static void main(String args[])
	{
	  String str = "SUMIT";
	  int len = str.length();


	  for (int i = 0; i < len; i++)
	  {
		for (int j = 1; j <= len; j++)
		{
		  System.out.print(str.charAt(len - j)+" ");
		}
		System.out.println();
	  }
	  
	}
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    string str = "SUMIT";
    int len = str.Length;


    for (int i = 0; i < len; i++)
    {
      for (int j = 1; j <= len; j++)
      {
        Console.Write(str[len - j] + " ");
      }
      Console.WriteLine();
    }


    Console.ReadKey(true);
  }
}

Python

string = "SUMIT"
length = len(string)

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

Related Patterns