Answers for "abbreviate name using string in c"

C
0

abbreviate name using string in c

#include <stdio.h>
#include <string.h>

void main()
{
    char str[100];

    int len,i,a;

    printf("enter your name: ");

    gets(str);

    len = strlen(str);

    printf("%c.",(str[0]));

    for(i=0;i<len;i++)
    {
        if(str[i]==' ')
        {
            a=i;
        }
    }

    for(i=0; i<a; i++)
    {
        if(str[i]==' ')
        {
            printf("%c.", str[i+1]);
        }
    }

    for(i=a+1;i<len;i++)
    {
        printf("%c",str[i]);
    }
}
Posted by: Guest on June-23-2021

Code answers related to "C"

Browse Popular Code Answers by Language