fork download
  1. //Q97. Print the initials of a name.
  2. #include <stdio.h>
  3. int main() {
  4. char str[100];
  5. int i;
  6. gets(str);
  7. if(str[0] != ' ')
  8. printf("%c.", str[0]);
  9. for(i=0; str[i]!='\0'; i++)
  10. if(str[i]==' ' && str[i+1]!=' ' && str[i+1]!='\0')
  11. printf("%c.", str[i+1]);
  12. }
  13.  
Success #stdin #stdout 0.01s 5316KB
stdin
John Doe
stdout
J.D.