In this article, we will write an interactive C program that reads a person’s full name and prints it in abbreviated form(first initial, then middle initial and then last name).
Example :
#include <stdio.h> int main() { char fname[20], mname[20], lname[20]; /* Read the full name */ printf("Enter full name in this format (first middle last): "); scanf("%s %s %s", fname, mname, lname); /* print abbreviated name */ printf("Abbreviated name is %c. %c. %s\n", fname[0], mname[0], lname); return 0; }
Output :
Enter full name in this format (first middle last): Harry James Potter
Abbreviated name is H. J. Potter
© 2017, https:. All rights reserved. On republishing this post, you must provide link to original post
#
if someone dont have middle name what we have to print