Day 3 Sample code
Initials
//DISPLAY 2.3 The type char
#include <iostream>
using namespace std;
int main( )
{
char symbol1, symbol2, symbol3;
cout << "Enter two initials, without any periods:\n";
cin >> symbol1 >> symbol2;
cout << "The two initials are:\n";
cout << symbol1 << symbol2 << endl;
cout << "Once more with a space:\n";
symbol3 = ' ';
cout << symbol1 << symbol3 << symbol2 << endl;
cout << "That's all.";
return 0;
}
Strings 2.4
//DISPLAY 2.4 The string class
#include <iostream>
#include <string>
using namespace std;
int main()
{
string middle_name, pet_name;
string alter_ego_name;
cout << "Enter your middle name and the name of your pet.\n";
cin >> middle_name;
cin >> pet_name;
alter_ego_name = pet_name + " " + middle_name;
cout << "The name of your alter ego is ";
cout << alter_ego_name << "." << endl;
return 0;
}
Srring example
This topic: SCMP118/Fall2016
> WebHome > CodeDay4
Topic revision: r1 - 2015-09-03 - JimSkon