Modify this program so that your program checks for the whole word and does
it in such a way that it will accept the word if it is typed with an initial
upper-case or lower-case letter and the remainder of the word is typed in
lower-case letters.
Try to make your program reasonably efficient. Note that a call to the
function strcmp is much more expensive that simply comparing one or two characters.
2. Identify and correct the error(s) in each of the following:
(a) if ( age >= 65 );
cout << "Age is greater than 65" << endl;
else
cout << "Age is less than 65 << endl";
(b) int x = 1, total;
while ( x <= 10 ) {
total += x;
++x;
}
(c) while ( y < 0 ) {
cout << y << endl;
++y;
}
{Based on Dietl & Dietl, Ex. 2.14, p 145.)
3. Rewrite the following for statement as an equivalent while statement:
for (i=0; i< max_lenth; i++) if (input_line[i] == '?') quest_count++;
(Stroustrup, Ex. 1, p. 140.)
4. Write these functions: strlen(), which returns the length of a C-style
string; strcpy() which copies a string into another; and strcmp, which compares
two strings. Consider what the argument types and return types ought to be.
Then compare your functions with the standard library versions as declared
in <cstring> (<string.h>) and as specified in the C library reference
section of the text that you are reading. Note that it is important to test
your functions. Include the test cases that you used in the main program that
you turn in with your functions.
(Stroustrup, Ex. 11, p. 141)