1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erma4kov [3.2K]
3 years ago
5

C++ a. Write a program that uses the function isPalindrome given in example 6-6 (Palindrome). Test your program on the followinn

g strings: "madam", "abba", "22", "67876", "444244", and "trymeuemyrt" b. Modify the function isPalindrome of example 6-6 so that when determining weather a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. Example 6-6: bool isPalindrome (string str) { int length = str.Length(); for (int i = 0; i < length / 2; i++) if (str[i] != str[length - 1 - i]; return false; return true; }
Computers and Technology
1 answer:
Whitepunk [10]3 years ago
5 0

Answer:

#include <iostream>

#include <array>

using namespace std;

bool isPalindrome(string str)  

{  

int length = str.length();  

for (int i = 0; i < length / 2; i++)  

 if (toupper(str[i]) != toupper(str[length - 1 - i]))

  return false;  

return true;  

}

int main()

{

array<string, 6> tests = { "madam", "abba", "22", "67876", "444244", "trymEuemYRT" };

for (auto test : tests) {

 cout << test << " is " << (isPalindrome(test) ? "" : "NOT ") << "a palindrome.\n";

}

}

Explanation:

The toupper() addition forces characters to uppercase, thereby making the comparison case insensitive.

You might be interested in
A. True <br> b. False: variables represent storage locations in the computer's memory.
SOVA2 [1]
B. False: variables represent storage locations in the computer's memory.
3 0
2 years ago
When an IRET instruction isexecuted, what action takes place?
andrey2020 [161]

Answer:

<u>IRET(Interrupt return) </u>

This instruction is used in x-86 intel cpu architecture.

The IRET instruction provides for a long return to the program or procedure interrupted. IRET and IRETD these two instructions have the same meaning.

Each interrupt procedure has an IRET instruction stating that the routine ends. The execution of the instruction pops up the IP address from the stack and continues to run the primary program.

7 0
3 years ago
Whixh options are available when a user modifies a recurring appointment. Check all that apply
Leno4ka [110]

Sorry I don’t know the answer I am really sorry
7 0
2 years ago
What does % find on edhesive??
statuscvo [17]

Answer:

Explanation: What is that word you typed?

3 0
2 years ago
While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar
sergejj [24]
When in slide show mode, the menu bar and that "x" are not visible.
5 0
3 years ago
Read 2 more answers
Other questions:
  • What three components make up a film camera?
    14·2 answers
  • Which routine is configured to be called by another routine?
    10·1 answer
  • What are some strategies that you can use when you debug a program?
    11·1 answer
  • An expression involving byte, int, and literal numbers is promoted to which of these?
    12·1 answer
  • How is the cia triad used to evaluate encryption methods?
    6·1 answer
  • A server of service is responsible for sending the contents of cengage.com to your browser when you type cengage.com into the lo
    12·1 answer
  • Generally speaking, problems are rarely caused by motherboards. However, there are some instances in which a motherboard can fai
    12·1 answer
  • NAT addresses concerns over the dwindling IPv4 address space by ___________________. 1 point allowing networks to use fewer IP a
    15·1 answer
  • What is the purpose of heading tags?
    15·1 answer
  • Lab 8-1: Working with Boot Loader and Runlevels what is the root password
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!