Program in C++ to print abbreviation of given full name.
#include<iostream> #include<string.h> using namespace std; int main() { char str[100],abb[40]; int j=0; cout<<"Enter Full Name :-"; cin.getline(str,30); for(int i=0;i<strlen(str);i++) { if(i==0){ abb[j]=str[i]; abb[++j]='.'; } else if(str[i]==' '){ abb[++j]=str[i+1]; abb[++j]='.'; } } cout<<"Abbreviation = "<<abb; return 0; }
Output:-
0 Comments