Print string of odd length in ' X ' format | C # program to print the given pattern ; Function to print the given string in respective pattern ; Print characters at corresponding places satisfying the two conditions ; Print blank space at rest of places ; Driver code
using System ; public class GFG { static void printPattern ( string str , int len ) { for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < len ; j ++ ) { if ( ( i == j ) || ( i + j == len - 1 ) ) Console . Write ( str [ j ] ) ; else Console . Write ( " ▁ " ) ; } Console . WriteLine ( ) ; } } static public void Main ( ) { String str = " geeksforgeeks " ; int len = str . Length ; printPattern ( str , len ) ; } }