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
MAXImum [283]
3 years ago
13

Write a program that uses the function isPalindrome given below. Test your program on the following strings: madam, abba, 22, 67

876, 444244, trymeuemyrt. Modify the function isPalindrome given so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. 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;
}
Engineering
1 answer:
defon3 years ago
5 0

Answer:

#include <iostream>

#include <string>

using namespace std;

bool isPalindrome(string str)

{

   int length = str.length();

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

   {

       if (tolower(str[i]) != tolower(str[length - 1 - i]))

           return false;

   }

   return true;

}

int main()

{

   string s[6] = {"madam", "abba", "22", "67876", "444244", "trymeuemyrt"};

   int i;

   for(i=0; i<6; i++)

   {

       //Testing function

       if(isPalindrome(s[i]))

       {

           cout << "\n " << s[i] << " is a palindrome... \n";

       }

       else

       {

           cout << "\n " << s[i] << " is not a palindrome... \n";

       }

   }    

       

   return 0;

}

You might be interested in
Find the differential and evaluate for the given x and dx: y=sin2xx,x=π,dx=0.25
Sedaia [141]

By applying the concepts of differential and derivative, the differential for y = (1/x) · sin 2x and evaluated at x = π and dx = 0.25 is equal to 1/2π.

<h3>How to determine the differential of a one-variable function</h3>

Differentials represent the <em>instantaneous</em> change of a variable. As the given function has only one variable, the differential can be found by using <em>ordinary</em> derivatives. It follows:

dy = y'(x) · dx     (1)

If we know that y = (1/x) · sin 2x, x = π and dx = 0.25, then the differential to be evaluated is:

y' = -\frac{1}{x^{2}}\cdot \sin 2x + \frac{2}{x}\cdot \cos 2x

y' = \frac{2\cdot x \cdot \cos 2x - \sin 2x}{x^{2}}

dy = \left(\frac{2\cdot x \cdot \cos 2x - \sin 2x}{x^{2}} \right)\cdot dx

dy = \left(\frac{2\pi \cdot \cos 2\pi -\sin 2\pi}{\pi^{2}} \right)\cdot (0.25)

dy = \frac{1}{2\pi}

By applying the concepts of differential and derivative, the differential for y = (1/x) · sin 2x and evaluated at x = π and dx = 0.25 is equal to 1/2π.

To learn more on differentials: brainly.com/question/24062595

#SPJ1

4 0
2 years ago
An ideal gas mixture has a volume base composition of 40% Ar and 60% Ne (monatomic gases). The mixture is now heated at constant
baherus [9]

[Find the attachment]

6 0
2 years ago
Find: factor of safety (n)for point A and B by using both MSS and DE (you can neglect shear stress due to shear force and also n
gladu [14]

Answer:

Hello your question is incomplete attached below is the complete question

Answer : Factor of safety for point A :

i) using MSS

(Fos)MSS =  3.22

ii) using DE

(Fos)DE = 3.27

Factor of safety for point B

i) using MSS

(Fos)MSS =  3.04

ii) using DE

(Fos)DE = 3.604

Explanation:

Factor of safety for point A :

i) using MSS

(Fos)MSS =  3.22

ii) using DE

(Fos)DE = 3.27

Factor of safety for point B

i) using MSS

(Fos)MSS =  3.04

ii) using DE

(Fos)DE = 3.604

Attached below is the detailed solution

8 0
3 years ago
This problem has been solved!
lisov135 [29]

Answer: a) 135642 b) 146253

Explanation:

A)

1- the bankers algorithm tests for safety by simulating the allocation for predetermined maximum possible amounts of all resources, as stated this has the greatest degree of concurrency.

3- reserving all resources in advance helps would happen most likely if the algorithm has been used.

5- Resource ordering comes first before detection of any deadlock

6- Thread action would be rolled back much easily of Resource ordering precedes.

4- restart thread and release all resources if thread needs to wait, this should surely happen before killing the thread

2- only option practicable after thread has been killed.

Bii) ; No. Even if deadlock happens rapidly, the safest sequence have been decided already.

5 0
2 years ago
At what times should you use your headlights?
SVETLANKA909090 [29]

Answer:

Headlights are required to be used 1/2 hour after sunset to 1/2 hour before sunrise, when windshield wipers are being used, when visibility is less than 1000 feet, or when there is insufficient light or adverse weather.

Explanation:

hope this helps

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is not one of the systems required to ensure the safe and correct operation of an engine?
    5·1 answer
  • The following is a list of metals and alloys:
    10·1 answer
  • Explain why the following acts lead to hazardous safety conditions when working with electrical equipmentA) Wearing metal ring o
    11·1 answer
  • A rectangular open channel is 20 ft wide and has a bed slope of 0.007. Manning's roughness coefficient n is 0.03. It is in unifo
    10·1 answer
  • An automobile engine consumes fuel at a rate of 22 L/h and delivers 85 kW of power to the wheels. If the fuel has a heating valu
    8·2 answers
  • Steam in a heating system flows through tubes whose outer diameter is 5 cm and whose walls are maintained at a temperature of 19
    13·1 answer
  • Plz give solutions..... ​
    6·1 answer
  • A Styrofoam cup (k = 0.010 W/(m∙ o C)) has cross-sectional area (A) of 3.0 x 10 −2m 2 . The cup is 0.589 cm thick (L). The tempe
    12·1 answer
  • Technician A states that air tools generally produce more noise than electric tools, so wear ear protection when using air tools
    8·1 answer
  • What is software certification? Discuss its importance in the changing scenario of software industry. ​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!