+ 4

Print initials of a person.

how to print initials of a person's name.. for ex-name is Anmol Sharma then output should be A. Sharma.. plz help me I am not able to do it it's very difficult..

1st Jan 2017, 6:06 AM
Mohd Sabahat
Mohd Sabahat - avatar
2 Antworten
+ 1
Take the name in string and store first character in char result_var. search for space and concatnate rest of word with result_var Let mr know if you need more clarification
1st Jan 2017, 6:19 AM
Shiv Kumar
Shiv Kumar - avatar
0
Hope this helps... #include <iostream> #include <string> using namespace std; int main() { string first, last; cout<<"Please enter your first and last name: "; cin>>first>>last; cout<<"Your initials are "<<first[0] <<last[0]<<endl; if ((first[0] == 'A') || (last[0] == 'A')) { cout<<endl<<"...*..."<<endl<<"..*.*.." <<endl<<".*...*."<<endl; cout<<".*****."<<endl<<"*.....*"<<endl;     }     return 0; }
1st Jan 2017, 7:25 AM
mingeun kim
mingeun kim - avatar