Write a c program to display the name in the following pattern. If the name is Rahul Das than it should display R.Das . Print abbreviation name: Tips:- Use character array to store stuff given by user. You need to use strlen function which is present in the string.h header file to find the length. Code:- #include<stdio.h> #include<string.h> //for strlen() funtion. void main() { char name[20]; int var=0,n=0; printf("Enter Your name :- "); gets(name); var=strlen(name); for(int i=0;i<=var;i++) { if(name[i]==' ') { n=i+1; } } printf("\nYour attribute is :- "); printf("%c.",name[0]); for(int j=n;j<var;j++) { printf("%c",name[j]); } printf("\n\n"); } Output:-
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)