c++ string program



#include<iostream.h> 
#include<string.h> 
int main() 

  char str[]="INDICODERZ"; 
  int len=strlen(str); 
  int i,j; 
  for (i=0; i<len; i++) 
  { 
    for (j=0; j<len; j++) 
    { 
      if (i==len/2) 
        cout<<str[j]<<" "; 
      else if (j==len/2) 
        cout<<str[i]<<" "; 
      else 
        cout<<"  "; 
    } 
    cout<<endl; 
  } 
  return 0; 



Output--


   I  
          N         
          D         
          I         
          C         
I N D I C O D E R Z 
          D         
          E         
          R         
           Z         

2 Comments

Post a Comment

Previous Post Next Post