Computer Science, asked by artisingh301, 7 months ago

Write a program to accept a name and print the initials except the last word of the name.
Example : Input : Mohan Das Karam Chand Gandhi
Output: M. D. K. C. Gandhi

Answers

Answered by Hannnnnnna
0

Answer: This is a program using c language. Hope its helpful

Explanation:

#include<stdio.h>

#include<string.h>

#include<ctype.h>

void main()

{  

   int i,s=0,s_i;

   char name[20];

   printf("Enter the Name:");

   gets(name);

   for(i=0;i<strlen(name);i++)

     if(name[i]==' ')

       {s_i=i;

       s++;}

   for(i=0;i<strlen(name);i++)

     if(i==s_i)

       break;

     else

      {

          if((i==0)||(name[i-1]==' '))

           printf("%c. ",toupper(name[i]));

      }

    for(i=i+1;i<strlen(name);i++)

     printf("%c",toupper(name[i]));

   

}

Similar questions