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]
2 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]2 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
Sam wants to move across the text and his documents to add data at predefined stops. Which key will Hughes to navigate through t
Setler [38]

Answer:

The TAB key

Explanation:

Sam would use the TAB key, located on the left side of the keyboard, to move around his document to add stops and format its information properly.

Pressing the TAB key will introduce a tab code in his document, which is like moving ahead by a certain number of spaces (5,6, 10 spaces for example, depending on the configuration of the document), but without using spaces, using a tab which is a much better option to position, align things up.

5 0
3 years ago
Which option describes wearable technology?
kotykmax [81]
My opinion is the answers A and D. I would choose A if you can only choose one, though.
7 0
3 years ago
Read 2 more answers
you crossed two heterozygous red flowers (dominant color), what are your chances to have a white flower
Lesechka [4]

Answer:

25% chance.

Explanation:

There is 25% chance it'll be h*m*zygous red, 50% chance it'll be h*t*rozygous red, and 25% chance it'll be h*m*zygous wh*te.

(Censored because it wouldn't let me post it for some reason. Honestly hope this doesn't work.)

4 0
2 years ago
Which of the following is NOT true of constructors? Question 6 options
LenKa [72]

Answer:

All are True

Explanation:

a. A constructor must have the same name as that of a class. For example

public class MyFirstClass{  // this is the class name

  public MyFirstClass() } // the constructor having the same name as class.

b. Constructors never have a return type not even void because it is only used to initialize the values of data members of the class when the object of the class is created so constructors are not directly called hence they do not need to have a return type.

c. Constructors are invoked using the new operator.

When the new object is created the constructor is invoked in order to initialize the variables of a class. The memory is allocated to the object and then the constructive is invoked for the purpose to initialize the object.

7 0
3 years ago
What was your first experience with listening to kpop?
Verizon [17]

Answer:

My first experience with kpop was when I was six I just danced to it lol I forgot the name of the song but it was funny watching the video of me.

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    11·2 answers
  • Walter’s health insurance premium increased by 22 percent this year. Now he pays $488 every month for health insurance. What was
    10·1 answer
  • The IT infrastructure components should be evaluated based on their expected financial value. All of the following are used to q
    15·1 answer
  • PLEASE PLEASE PLEASE PLEASE PLEASE HELP! I'M BEGGING Y'ALL! I NEED THIS FOR TODAY! CORRECT ANSWERS WILL BE AWARDED BRAINLIEST!
    6·1 answer
  • According to the "multiple-selves" theory, of an online DVD rental service could offer same-day deliveries, so that people who o
    9·1 answer
  • How many characters does the "short text" have?
    9·1 answer
  • Select the education and qualifications that are most helpful for business analysis careers. Check all that apply
    11·2 answers
  • A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
    9·1 answer
  • On a rheostat the first terminal is connected to a
    14·1 answer
  • _____ are fields that are used to personalize a mail merge document
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!