Provide array type declarations for representing the following: -A group of rooms (living room, dining room, kitchen and so on) that have a given area -A group of rooms as in the previous statement, but the array elements should indicate whether the room is carpeted -Elementary school grade levels (0 through 6, where 0 means kindergarten) with a given number of students per grade -A selection of colors (strings) representing the eye color of five people -A new answer for the previous, assuming each array element stores an enumerator from the enumeration type: typedef color = {blue, green, hazel, brown, black}; -An array daysInMonth with 31 number of days in January) in element 0, 28 (number of days in February) in element 1, and so on |
|
|
Write a program to store in string reverse the characters in string message, and to display "Is a palindrome" if message and reverse contain the same string. Provide input statements that will read values into both data items, and will let you repeat the reading, reversing, and displaying until the user indicates a desire to exit the program. Solving the Problem: Use the Exploration Journal to develop and document a solution design for this program. It does NOT need to be terribly elaborate, as the key objective is to practice accessing elements of the two string data items directly in order to accomplish the reversing action. Remember that strings can be compared directly, although they can also be compared character by character. If you do this, remember that one of the requirements for equality of strings is equality of length (which should not be a problem is this situation). |
|
|
|
|
4 |
|
|
aext |
|
|
Enter in a word: mom message: m reverse: m message: o reverse: o message: m reverse: m The word is not a palindrome. Would you like to enter in a new word (Yes or No)? no Press any key to continue . . . Process returned 0 (0x0) execution time : 2.998 s Press any key to continue. |
|
|
reverse[strlen(message)]='\0';
on the next line after the for loop. That way the program knows where the string ends. Tell me if that works.reverse[position]=letter;
with reverse.push_back(letter);
. Then you'd also have to include a reverse.clear();
before the for loop to empty reverse every time the user enters a new word.
|
|
if(message == reverse);
, which I think is checking to see if the addresses, and not the content, of the arrays are the same. So if you use arrays, you'd have to check element by element.
|
|
|
|
Enter in a word: word message: d reverse: d message: r reverse: r message: o reverse: o message: w reverse: w The word is not a palindrome. Would you like to enter in a new word (Yes or No)?yes Enter in a word: mom message: m reverse: m message: o reverse: o message: m reverse: m The word is not a palindrome. Would you like to enter in a new word (Yes or No)?no Press any key to continue . . . Process returned 0 (0x0) execution time : 16.830 s Press any key to continue. |