-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (30 loc) · 859 Bytes
/
main.cpp
File metadata and controls
38 lines (30 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//this program is to print out the initials.
//if the name is written in lowercase, it will automatically be converted to uppercase
#include <iostream>
//to use getline
#include <string>
#include <sstream>
using namespace std;
void getInitials(string s){
istringstream ss(s); //extract each word in the sentence
string first_name, last_name; //for storing each word
ss >> first_name;
cout<<first_name<<".";
while (ss >> last_name){
// print the read word
cout << (char)toupper(last_name[0])<< ".";
}
}
int main()
{
string name;
cout<< "Hi!"<<endl;
cout<< "I am here to help you print the initials of your name. :)"<<endl;
cout<< "Enter your name here : ";
getline(cin, name);
cout<< "*********"<<endl;
getInitials(name);
endl(cout);
cout<< "*********"<<endl;
return 0;
}