#include <iostream>
using namespace std;
int main()
{
int age=26;
cout << "I am " << age << " years old" << endl;
age++; /* add one */
cout << "Next year I will be " << age << endl;
return 0;
}
#include <string>
#include <iostream>
int main(void)
{
std::string s1 = "Hello World";
std::string s2 = "Hello";
std::string s3 = " World";
s2 += s3;
if(s1 == s2)
{
std::cout << "LOOK - EASY!!!\n";
return(0);
}
else
{
std::cout << "Oops!\n";
return(1);
}
}
#include <string>
#include <iostream>
int main(void)
{
std::string s1 = "Hello World\n";
std::cout << s1;
std::cout << "Hello again" << std::endl;
}
This exercise is taken from the first chapter of "Essential C++"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string user_name;
cout << "Please enter your first name: ";
cin >> user_name;
cout << endl
<< "Hello, "
<< user_name
<< "... And goodbye!" << endl;
return 0;
}
// #include <string>Now recompile the program. What happens?
main() to my_main(). What happens?