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
2+2? D: I don't knoww​
Grace [21]

Answer:4

Explanation:

just bc it is

5 0
3 years ago
What are the synonyms for each word? :
lyudmila [28]
Ok sistah, me got you, 
(1) gather together, or increasing number
(2) price or amount charged
(3) intentionally 
(4) Take or seize
(5) extremely large or great
(6) savagely fierce or violent 
(7)<span>irritate intensely
(8) miffed
(9)</span><span>well meaning and kindly
(10) pensive

Hope i helped :)</span>
8 0
3 years ago
_____ create computer programs by using their knowledge of computer science, math, and other disciplines.
zimovet [89]
B.) Software designers
5 0
3 years ago
It is considered good practice to save a presentation before printing it. true false
Ilya [14]
It is true because it is really a good practise to save a presentation before printing it

5 0
3 years ago
You are the network administrator for a company with a single Active Directory domain. The corporate office is located in Miami
Lubov Fominskaja [6]

Answer: throw your computer out of the window because to hell with this question

Explanation:

4 0
3 years ago
Other questions:
  • PLZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    11·2 answers
  • 1. Itemise the order in which BASIC executes arithmetic operation.
    13·1 answer
  • Exploring Arraylists. Remember that arraylists are good for adding and removing things, and that they are clock-cycle friendlier
    13·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • You should always assign the Needs Met rating before assigning the Page Quality rating, T or F ?
    6·2 answers
  • PLZ HELP FAST!!!! 
    7·2 answers
  • ____________________ is the primary code humans use to communicate. (Points : 1
    9·1 answer
  • Var1 = 1<br> var2 = 2<br> var3 = "3"<br> print(var1 + var2 + var3)
    5·1 answer
  • What is software?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!