Contact Learn C
Copy

Program 260: Program to print String in X Pattern(Reverse) in C

Program 260: Program to print String in X Pattern(Reverse) 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);
 strrev(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(Reverse) output

Program to print String in X Pattern(Reverse) output

Donate

Download App and Learn when ever you want

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