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
Human centered technology often recommends a0 to computer designers and manufacturers, telling them how to make systems and the
IceJOKER [234]

Human centered technology often recommends best practices to computer designers and manufacturers, ...............

Human-Computer Interaction is a study that particularly focuses more on the design of computer technology and the interaction between humans and computers. Since the 1980s when HCI surfaced, it has become a crucial tool in popularizing the idea that the interaction between a user and a computer should resemble a human-to-human, open-ended dialogue. When HCI is done well, a human-centered approach powers the creation of products that resonates more deeply with a certain audience. This will ultimately drive engagement and growth.

6 0
3 years ago
Read 2 more answers
Notes on secondary memory​
gladu [14]

Answer:

non-volatile and persistent in nature

7 0
3 years ago
Use the variables k, d, and s so that they can read three different values from standard input--an integer, a double, and a stri
Nat2105 [25]

Answer:

The c++ program to implement the given scenario is shown below.

#include <iostream>

using namespace std;

int main() {

   // variables declared as mentioned

   int k;

   double d;

   string s;

   cout << " Enter an integer value, a double value, a string value in the mentioned order " << endl;

   cin >> k >> d >> s;

   // variables printed in reverse order

   cout << " Reverse order " << endl;

   cout << s << " " << d << " " << k << endl;

   // variables printed in original order

   cout << " Original order " << endl;

   cout << k << " " << d << " " << s << endl;

   return 0;

}

OUTPUT

Enter an integer value, a double value, a string value in the mentioned order  

12 45.67 brainly

Reverse order  

brainly 45.67 12

Original order  

12 45.67 brainly

Explanation:

1. All the variables are declared as mentioned in the question.

int k;

   double d;

   string s;

2. The user is prompted to enter values for integer, double and string variables respectively. The input is accepted in the order mentioned above.

cin >> k >> d >> s;

3. The input is accepted in a single line since this is mentioned in the scenario that variables should be printed in the order in which they are read.

4. These variables are displayed to the standard output in reverse order – string, double, integer. The variables are displayed with exactly one space in between them.

cout << s << " " << d << " " << k << endl;

5. Then, variables are displayed in the original order – integer, double, string. The variables are displayed with exactly one space in between them.

cout << k << " " << d << " " << s << endl;

7 0
3 years ago
Which of the following is NOT a popular computer programming
cestrela7 [59]
Answer is Xero. All the other Languages are Popular and Widely Used.
Thank You!
6 0
2 years ago
At the data science laboratory, the data scientists and data engineers are required to process millions of data every second to
defon

Answer:

the type of computer system that is required for processing of scientific data is : supercomputer

for distribution of data over a network :Client/server computing

working from home :A laptop

3 0
3 years ago
Other questions:
  • Briefly explain the cooling mechanism implemented in a fanless laptop
    15·1 answer
  • Which protocol, as a companion protocol to RTP, provides monitoring and reporting for RTP connections?
    14·1 answer
  • You often insert your company's logo into documents you create. One way to make it easier for you to quickly insert it is to sav
    10·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
  • When adding cells you must use a "+" symbol, you cannot use a ":" symbol.<br><br> ☐ True<br> ☐ False
    13·1 answer
  • Elsa wants to save her work at the office to be continued at home either on a pen drive or CD. Outline three reasons why she wil
    6·1 answer
  • Explain what led to the invention of lasers
    7·1 answer
  • Describe how a user would interact with a smart-phone to do various tasks.Consider inputs and outputs.
    12·1 answer
  • You are the Emergency Management Director of a small island nation. Your nation has come under Cyber-attack and the attackers ha
    7·1 answer
  • You are reviewing a friend’s HTML project. You notice that the only metadata is the title. Furthermore, you ask your friend abou
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!