#include<iostream>intmain(){
using std::cin;using std::cout;char ch;int spaces =0;int total =0;
cin.get(ch);while(ch !='.'){
if(ch ==' '){
++spaces;}++total;
cin.get(ch);}
cout << spaces <<" spaces, "<< total;
cout <<" characters total in sentence\n";return0;}
6.2 ifelse.cpp
#include<iostream>intmain(){
char ch;
std::cout<<"Type , and I shall repeat.\n";
std::cin.get(ch);while(ch !='.'){
if(ch =='\n'){
std::cout << ch;}else
std::cout <<++ch;
std::cin.get(ch);}
std::cout <<"\n Please excuse the slight confusion.\n";return0;}
6.3 ifelseif.cpp
#include<iostream>constint Fave =27;intmain(){
usingnamespace std;int n;
cout <<"Enter a number in the range 1-100 to find ";
cout <<"my favorite number:";do{
cin >> n;if(n < Fave)
cout <<"Too low -- guess again:";elseif(n > Fave)
cout <<"Too high -- guess again:";else
cout << Fave <<" is right!\n";}while(n != Fave);return0;}
6.4 or.cpp
#include<iostream>intmain(){
usingnamespace std;
cout <<"This program may reformat your hard disk\n""and destory all your data.\n""Do you wish to continue?<y/n>";char ch;
cin >> ch;if(ch =='y'|| ch =='Y')
cout <<"You were warned!\a\a\n";elseif(ch =='n'|| ch =='N')
cout <<"A wise choic ...bye\n";else
cout <<"That wasn't a y or n!Apparently you ""can't follow\ninstructions,so ""I'll trash your disk anyway.\a\a\a\n";return0;}
6.5 and.cpp
#include<iostream>constint ArSize =6;intmain(){
usingnamespace std;float naaq[ArSize];
cout <<"Enter the NAAQs (New Age Awareness Quotients) "<<"of \nyour neighbors. Program terminatesc "<<" when you make\n"<< ArSize <<" entries "<<" or enter a negative value.\n";int i =0;float temp;
cout