Print the word with odd number of letters as
P         M
 R      A
   O  R
     G
  O    R
 R       A
P          M 
#include<stdio.h> #include<string.h> #include<stdlib.h> void main() { int n,i,j,k,l; char str[20]; printf("Enter a string with odd number of letters."); scanf("%s",str); if((n=strlen(str))%2==0) { printf("\nNot odd"); exit(0); } for(i=0;i<n;i++) { printf("\n"); for(j=0;j<n;j++) { if(i==j||j==n-1-i) printf("%c",str[j]); else printf(" "); } } }
No comments:
Post a Comment