#include<iostream>#include<climits>#defineZERO0;intmain(){usingnamespace std;short sam = SHRT_MAX;unsignedshort sue = sam;
cout <<"Sam has "<< sam <<" dollars and Sue has "<< sue;
cout <<" dollars deposited."<< endl
<<"Add $1 to each account."<< endl <<"Now ";
sam = sam +1;
sue = sue +1;
cout <<"Sam has "<< sam <<" dollars and Sue has "<< sue;
cout <<" dollars deposited.\nPoor Sam!"<< endl;
sam = ZERO;
sue = ZERO;
cout <<"Sam has "<< sam <<" dollars and Sue has "<< sue;
cout <<" dollars deposited."<< endl;
cout <<"Take $1 from each account."<< endl <<"Now ";
sam = sam -1;
sue = sue -1;
cout <<"Sam has "<< sam <<" dollars and Sue has "<< sue;
cout <<" dollars deposited."<< endl <<"Lucky Sue!"<< endl;return0;}
3.3 hexoct.cpp
#include<iostream>usingnamespace std;intmain(){int chest =42;int waist =0x42;int inseam =042;
cout <<"Monsieur cuts a striking figure!\n";
cout <<"chest = "<< chest <<"{42 in decimal}\n";
cout <<"waist = "<< waist <<"{0x42 in hex}\n";
cout <<"inseam = "<< inseam <<"{042 in octal}\n";return0;}
#include<iostream>intmain(){usingnamespace std;char ch;
cout <<"Enter a character: "<< endl;
cin >> ch;
cout <<"Hola! ";
cout <<"Thank you for the "<< ch <<" character."<< endl;return0;}
3.6 morechar.cpp
#include<iostream>usingnamespace std;intmain(){char ch ='M';int i = ch;
cout <<"The ASCII code for "<< ch <<" is "<< i << endl;
cout <<"Add one to the character code:"<< endl;
ch = ch +1;
i = ch;
cout <<"The ASCII code for "<< ch <<" is "<< i << endl;
cout <<"Displaying char ch using cout.put(ch): ";
cout.put(ch);
cout.put('!');
cout << endl <<"Done"<< endl;return0;}
3.7 bondini.cpp
#include<iostream>usingnamespace std;intmain(){
cout <<"\aOperation \"HyperHype\" is now activated!\n";
cout <<"Enter your agent code:_________\b\b\b\b\b\b\b\b";long code;
cin >> code;
cout <<"\aYou entered "<< code <<"...\n";
cout <<"\aCode verified! Proceed with Plan z3!\n";return0;}
3.8 floatnum.cpp
#include<iostream>usingnamespace std;intmain(){
cout.setf(ios_base::fixed, ios_base::floatfield);float tub =10.0/3.0;double mint =10.0/3.0;constfloat million =1.0e6;
cout <<"tub = "<< tub;
cout <<", a million tubs = "<< million * tub;
cout <<", \nand ten million tubs = ";
cout <<10* million * tub << endl;
cout <<"mint = "<< mint <<" and a million mints = ";
cout << million * mint << endl;return0;}
3.9 fltadd.cpp
#include<iostream>intmain(){usingnamespace std;float a =2.34E+22f;float b = a +1.0f;
cout <<" a = "<< a << endl;
cout <<"b - a = "<< b - a << endl;return0;}