patternprogram_424 softethics

Pattern 424 (String Pattern)

C

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

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

  for (i=0; i<len; i++)
  {
    for (j=0; j<len; j++)
    {
      if (i==len/2)
        printf("%c ",str[j]);
      else if (j==len/2)
        printf("%c ",str[i]);
      else
        printf("  "); // 2ws
    }
    printf("\n");
  }
  return 0;
}

C++

Java

C#

Python

5 2 votes
Rate this Program
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments