Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78918926
ch-01-ex-05-solution.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 23, 18:17
Size
986 B
Mime Type
text/x-c
Expires
Sun, Aug 25, 18:17 (2 d)
Engine
blob
Format
Raw Data
Handle
20122186
Attached To
R9360 PCSC_git
ch-01-ex-05-solution.cpp
View Options
/*
* exercise05.cpp
*
* Input your first and last name as two separate strings and
* use them to print your full name on the screen.
*
* Created on: Jul 27, 2012
* Author: Radu Popescu <radu.popescu@epfl.ch>
*/
#include <iostream>
// We are using std::string variables, so we need to include the string header
#include <string>
int
main
(
int
argc
,
char
*
argv
[])
{
// Read the first and last name as two separate strings
std
::
string
first_name
;
std
::
cout
<<
"Please input your first name: "
;
std
::
cin
>>
first_name
;
std
::
string
last_name
;
std
::
cout
<<
"Please input your last name: "
;
std
::
cin
>>
last_name
;
// Print the full name as two arguments to std::cout
std
::
cout
<<
"Your full name is "
<<
first_name
<<
" "
<<
last_name
<<
std
::
endl
;
// Or concatenate the two strings and print the new variable
std
::
string
full_name
=
first_name
+
" "
+
last_name
;
std
::
cout
<<
"Your full name is "
<<
full_name
<<
std
::
endl
;
return
0
;
}
Event Timeline
Log In to Comment