+ 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..
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
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;
}