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
Assume passwords are selected from four character combinations of 26 lower case alphabetic characters. Assume an adversary is ab
finlep [7]

Answer:

Given:

Passwords are selected from 4 characters.

Character combinations are 26 lower case alphabetic characters.

Passwords attempts by adversary is at rate of 1 second.

To find:

Expected time to discover the correct password

Explanation:

Solution:

4 character combinations of 26 alphabetic characters at the rate of one attempt at every 1 second = 26 * 4 = 104

So 104 seconds is the time to discover the correct password. However this is the worst case scenario when adversary has to go through every possible combination. An average time or expected time to discover the correct password is:

13 * 4 = 52

You can also write it as 104 / 2 = 52 to discover the correct password. This is when at least half of the password attempts seem to be correct.

3 0
3 years ago
Kate saves her work on a secondary storage device that is fairly new, and uses flash technology instead of disks.
almond37 [142]

Answer:

B.) SSD

Explanation:

I hope I helped! ^-^

8 0
3 years ago
If you were investigating login issues on a Windows computer, which portion of the Event Viewer logs would be a good place to st
USPshnik [31]

Answer:

If we are investigating login issues then we have to start with 'security logs' in 'windows logs' portion of Event viewer.

Explanation:

Much information about login issues is contained in log files which are related to security because it is mostly security issue. Some it is also better to start with 'system logs' portion of windows logs portion of Event viewer when there may be system problems instead of security issues. But in most cases there is security issues so 'security logs' is better option overall

6 0
4 years ago
Some people are unable to arrange six matches to form four equilateral triangles because they fail to consider a three - dimensi
Andre45 [30]

Answer:

a. fixation

Explanation:

Fixation, also called functional fixedness, is one of the most common factors that limit the ability of people to solve a problem. In this cognitive bias, a person is only able to use objects in ways they are normally used. Any attempt to use it in other ways to solve a problem is almost impossible.

Fixation really affects creativity. It limits the way people think. It makes people have a parochial view of the way an object can be used. It blocks the thinking ability from seeing alternative approaches to solving a problem.

3 0
4 years ago
Certain high-performance vehicles use a dry sump system because it allows for A. more power. B. longer periods of cornering and
snow_lady [41]

The correct answer is C: All of these options.

Vehicles that use dry sump system have greater oil capacity. With that, the engine has more power, it can improve up to 15 horsepower when switching from wet dry sump to dry sump system. Also, when the vehicle has more oil capacity, it means that they are heavier and because of that there are longer periods of cornering and braking.


6 0
4 years ago
Read 2 more answers
Other questions:
  • Do all accounts use the same routing number
    12·1 answer
  • How can ASCII be used to represent characters in a computer system?
    15·1 answer
  • The encapsulation unit on the data link layer of the osi model is _________
    10·1 answer
  • Edhesive 4.1 question 1
    9·1 answer
  • Businesses finance their operations using a mixture of ______. debt,
    14·1 answer
  • Which of these is NOT a reason why you would print handouts of your presentation?
    14·1 answer
  • Which of the following is not the name of an air mass?
    7·1 answer
  • A program executes 100 billion instructions. It executes on an IBM processor that has an average CPI of 1.2 and a clock frequenc
    15·1 answer
  • Drag each tile to the correct box.
    8·1 answer
  • To celebrate me reaching expert in the same day i made the account im doing a point giveaway
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!