by Dinesh Thakur Category: C Programming (Pratical)

Let us use character arrays fname, mname and lname to store the first name, middle name and last name of a person. The program given below first accepts the full name, i. e., values of fname, mname and lname using a scanf function. Then the name is printed in the desired abbreviated form using a printf function. The initial letters of fname and mname are printed using fname [0]and mname[0], respectively. The program is given below.

/* Write person's name in abbreviated form */

#include <stdio.h>

int main()


    char fname[20], mname[20], lname[20]; /* person's name */

      /* accept full name */

     printf("Enter full name (first middle last): ");

     scanf("%s %s %s", fname, mname, lname);

      /* print abbreviated name */

     printf("Abbreviated name: ");

     printf("%c. %c. %s\n", fname[0], mname[0], lname);

     return 0;


The program output is given below.

Enter full name (first middle last): Dinesh Kumar Thakur

Abbreviated name: D. K. Thakur

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.