ch2-HeYou (Hey, you)

Chapter_2     Exercise_2-2     HelloStrings Scopy     Exercise_2-3







Note:  This is another solution of Exercise 2-1.




HeYou.cpp         download


// 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!
*/









Chapter_2     Exercise_2-2     HelloStrings BACK_TO_TOP Scopy     Exercise_2-3



Comments

Popular posts from this blog

Contents