Note:
This is another solution of Exercise 2-1.
// Saying Hello with C++
#include <iostream> // Stream declarations
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
int main()
{
int age;
string first, last;
cout << "First name: ";
cin >> first;
cout << "Last name: ";
cin >> last;
cout << "Age: ";
cin >> age;
cout << "Hello, world! My name is " << first << " " << last
<< ". I am " << age << " today!" << endl;
}
/*
g++ HeYou.cpp -o HeYou
./HeYou
First name: John
Last name: Doe
Age: 8
Hello, world! My name is John Doe. I am 8 today!
*/
Comments
Post a Comment