Contact Learn C
Copy Program Share Program

Program 259: Program to print String in X Pattern in C

Program 259: Program to print String in X Pattern in C

#include<stdio.h>
#include<string.h>
main()
{
 int len,i,j;
 char str[100];
 printf("Enter a string to get X Pattern\n");
 gets(str);
 len=strlen(str);
 for(i=0;i<len;i++)
 {
  for(j=0;j<len;j++)
  {
   if(i==j || i+j==len-1)
   {
    printf("%c",str[i]);
   }
   else{
    printf(" ");
   }
  }
  printf("\n");
 }
}
Explanation:

//Coming Soon

Output:

Program to print String in X Pattern in C

Program to print String in X Pattern in C






Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide