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
brilliants [131]
3 years ago
7

Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following string

s: madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. The isPalindrome function from Example 6-6 has been included below for your convenience.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:
Artist 52 [7]3 years ago
6 0

Answer:

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(string str)

{

   char a,b;

int length = str.length();

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

{

   a=tolower(str[i]);//Converting both first characters to lowercase..

   b=tolower(str[length-1-i]);

   if (b != a )

return false;

}

return true;

   

}

int main() {

   string t1;

   cin>>t1;

   if(isPalindrome(t1))

   cout<<"The string is Palindrome"<<endl;

   else

   cout<<"The string is not Palindrome"<<endl;

return 0;

}

Output:-

Enter the string

madam

The string is Palindrome

Enter the string

abba

The string is Palindrome

Enter the string

22

The string is Palindrome

Enter the string

67876

The string is Palindrome

Enter the string

444244

The string is not Palindrome

Explanation:

To ignore the cases of uppercase and lower case i have converted every character to lowercase then checking each character.You can convert to uppercase also that will also work.

You might be interested in
Describe how you would create a Java program that prompted the user to correctly enter a username and password. The username is
schepotkina [342]

Answer:

Explanation:

The program in question would create a new Scanner Object which asks the user for the Username first. It would then save this input into a temporary variable and compare it to the actual username in the database. Since the username is not case sensitive, we would use the toLowerCase() method on both the input and the database username so that they match even if the letters are not the same case structure. If both usernames match then we would move on to ask the user for the Password and compare it with the database password for that user. Since this one is case sensitive we would compare as is. Finally, if both Username and Password match we would print "Hello World" otherwise we would print "Login Failed."

3 0
2 years ago
Vendors who use open source as part of their product offerings can expect to bring new products to the market faster because: Gr
tamaranim1 [39]

Answer:

A.  they can skip whole segments of the software development process.

Explanation:

A software development process refers to the process of dividing software development work into various phases for product management, project management and to improve the design.

Vendors who use open source as part of their product offerings can expect to bring new products to the market faster because they can skip whole segments of the software development process.

They don't have to go through different phases of software development.

6 0
3 years ago
According to your textbook, the three major criteria against which to test documents that you locate on the Internet are authors
pantera1 [17]

Answer:

The following statement is False.

Explanation:

Because asper textbook there are only one main criteria against the test documents that find on the internet i.e., authorship. So, that's why the following given statement is false. The graphic and the interactivity depends on the quality of the document this options do not come under the criteria to test the document.

6 0
3 years ago
Mention how to install antivirus software in your computer, either by following the instructions given on installation CDs or we
Tema [17]

Answer:

ionow please help me

Explanation:

5 0
3 years ago
HEYY GUYS START REPORTING ALL THE SPAMMERS PLSS!!!!! For the spammers, I hope you go to hell &gt;:c!!!!!!!!!!!
Molodets [167]

Answer:

i totally agree

Explanation:

4 0
3 years ago
Other questions:
  • Which area of the network would a college it staff most likely have to redesign as a direct result of many students bringing the
    10·1 answer
  • Please help. 15 points!!!!
    8·2 answers
  • The Linux operating system was created by which software engineer?
    15·1 answer
  • What is the name of the process that weighs the alternatives, gathers all necessary information, and can ultimately lead you to
    9·2 answers
  • When your hands are on home row, your left hand rests lightly on _____. J K L ; A S D F Z X C V Q W E R'
    11·1 answer
  • By the 1990s, ______________ technology enabled one person operating a desktop computer to control most—or even all—of these fun
    8·2 answers
  • What is the output of the following program?
    11·1 answer
  • Who has gotten a random file link from someone? What file does it contain?
    8·2 answers
  • FILL IN THE BLANK.
    10·1 answer
  • As a member of the help desk administration team, you've been assigned to update the driver for the network adapter that is inst
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!