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]
4 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]4 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 user who enters americanbank.net into a web browser instead of the correct americanbank and is then taken to a fake look-alike
Vlada [557]

Answer:

Typosquatting is the correct answer.

Explanation:

Typosquatting is another type of cybersquatting in which any user or person enters into the others sites from the web browser and then, they create another fake that is usually same as that site. They also create that type of address of the fake websites that is somewhere similar to the original and these are illegal in many countries.

6 0
4 years ago
Read 2 more answers
One way to avoid carbon monoxide poisoning is to:<br><br> B. Open a rear window in your car
natali 33 [55]

What's the question?

4 0
3 years ago
Describe the importance of prioritizing your focus when designing for multiple purpose
sp2606 [1]
<span>While Designing for Multiple purpose the prioritizing our focus is an essential part, when missed can lead to vague information and may spoil the sole purpose of the product that was meant to be designed. Our focus should always point to the MVP or Minimum Viable Product that needs to be delivered and on top what type of aspects we bring in to serve the multiple purpose need. The focus on order of prioritization should never be compromised unless there is something very essential that was left without incorporating at the designing stage.</span>
3 0
3 years ago
Limitations of systems analysis and design​
Sonja [21]

Answer:

<h3 />

Explanation:

<h3>Although System analysis offers an extensive range of benefits it might also have some disadvantages. One of the main disadvantages which is mostly overlooked is the risk of too much analysing which may be costly and time consuming. It is therefore part of the analyst's job to find the right balance.</h3>
6 0
3 years ago
Which is a basic job requirement for a career in corrections services?
Diano4ka-milaya [45]

You must have a high school diploma

7 0
3 years ago
Other questions:
  • In Rizzati Corp, vice presidents in departments such as engineering, manufacturing, IT, and human resources report directly to t
    15·1 answer
  • How does a main program recieve info from a function in c++?
    6·1 answer
  • In python:
    14·1 answer
  • What is cloud computing?
    9·1 answer
  • Complete the following sentences.
    11·1 answer
  • Which of the following components converts AC to DC?
    5·1 answer
  • True or False? Threat modeling is the practice of identifying and prioritizing potential threats and security mitigations to pro
    9·1 answer
  • 4. When working at the CLI in Linux, you specify the exact location of a file, which is the ____________________ to it, by begin
    13·1 answer
  • Say true or false. a)ICT in education is used as teaching learning aid
    9·1 answer
  • Shreya has combined all the cells in a single leftmost column in a table. Instead of identifying the category multiple times, sh
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!