Saturday 29 August 2015

C code which prints initial of any name

C code which prints initial of any name


#include<stdio.h>
int main(){
   char str[20];
   int i=0;
   printf("Enter a string: ");
   gets(str);
   printf("%c",*str);
   while(str[i]!='\0'){
       if(str[i]==' '){
            i++;
            printf("%c",*(str+i));
       }
       i++;
   }
   return 0;
}

Sample output:

Enter a string: ANKITHA GOWDA
 AG

Leave a Reply

 
 

Labels

Blog Archive