Pattern 410 (String Pattern)

Pattern 410 (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 = 0; j < len; j++)
    {
      printf("%c ", str[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 = 0; j < len; j++)
    {
      cout<<str[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 = 0; j < len; j++)
		{
		  System.out.print(str.charAt(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 = 0; j < len; j++)
      {
        Console.Write(str[j] + " ");
      }
      Console.WriteLine();
    }

    Console.ReadKey(true);

  }
}

Python

string = "SUMIT"
length = len(string)

for x in range(0, length):
  for y in range(0, length):
    print(string[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