Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102848534
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
Mon, Feb 24, 19:53
Size
969 B
Mime Type
text/x-c
Expires
Wed, Feb 26, 19:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24440273
Attached To
R1106 Programming Concept Rouaze
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