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
A closed, rigid tank is filled with a gas modeled as an ideal gas, initially at 27°C and a gage pressure of 300 kPa. If the gas
ch4aika [34]

Answer:

gauge pressure is 133 kPa

Explanation:

given data

initial temperature T1 = 27°C = 300 K

gauge pressure = 300 kPa = 300 × 10³ Pa

atmospheric pressure = 1 atm

final temperature T2 = 77°C = 350 K

to find out

final pressure

solution

we know that gauge pressure is = absolute pressure - atmospheric pressure so

P (gauge ) = 300 × 10³ Pa - 1 × 10^{5} Pa

P (gauge ) = 2 × 10^{5} Pa

so from idea gas equation

\frac{P1*V1}{T1} = \frac{P2*V2}{T2}   ................1

so {P2} = \frac{P1*T2}{T1}

{P2} = \frac{2*10^5*350}{300}

P2 = 2.33 × 10^{5} Pa

so gauge pressure = absolute pressure - atmospheric pressure

gauge pressure = 2.33 × 10^{5}  - 1.0 × 10^{5}

gauge pressure = 1.33 × 10^{5} Pa

so gauge pressure is 133 kPa

4 0
3 years ago
Cuáles son los sentidos comunes que se pueden utilizar, para identificar un metal, gases o líquido
Vadim26 [7]

Answer:

A solid has definite volume and shape, a liquid has a definite volume but no definite shape, and a gas has neither a definite volume nor shape.

Explanation:

8 0
3 years ago
Given an integer k, a set C of n cities c1, . . . , cn, and the distances between these cities dij = d(ci , cj ), for 1 ⤠i &lt
Snezhnost [94]

Answer:

See explaination

Explanation:

2-Approximation Algorithm

Step 1: Choose any one city from the given set of cities C arbitrarily and put it in to a set H which is initially empty.

Step 2: For every city c in set C that is currently not present in set H compute min_distc = Minimum[ d(c, c1), d(c, c2), d(c, c3), ..... . . . . d(c, ci) ]

where c1, c2, ... ci are the cities in set H

and d(x, y) is the euclidean distance between city x and city y

Step 3: H = H ∪ {cx} where cx is the city have maximum value of min_dist over all possible cities c, computed in Step-2.

Step 4: Step-2 and Step-3 are iterated for k-1 times so that k cities are included int set H.

The set H is the required set of cities.

Example

Assume:-

C = {0, 1, 2, 3}

d(0,1) = 10, d(0,2) = 7, d(0,3) = 6, d(1,2) = 8, d(1,3) = 5, d(2,3) = 12

k = 3

Solution:-

Initially H = { }

Step-1: H = {0}

Step-2: Cities c \not\in H are {1, 2, 3}

min_dist1 = min{dist(0,1)} = min{10} = 10

min_dist2 = min{dist(0,2)} = min{7} = 7

min_dist3 = min{dist(0,3)} = min{6} = 6

Step-3: Max{10, 7, 6} = 10

Step-4: cx = 1

Step-5: H = H ∪ cx = {0} \cup {1} = {0, 1}

Step-6: Cities c \not\in H are {2, 3}

min_dist2 = min{dist(0,2), dist(1,2)} = min{7, 8} = 7

min_dist3 = min{dist(0,3), dist(1,3)} = min{6, 5} = 5

Step-7: Max{7, 5} = 7

Step-8: cx = 2

Step-9: H = H \cup cx = {0, 1} \cup {2} = {0, 1, 2}

Result: The set H is {0, 1, 2}.

6 0
3 years ago
While supporting load P, the maximum contraction permitted in a 4.75-m long pipe column is 7 mm. Given that E =180 GPa for the c
Alexeev081 [22]

Answer:

\mathbf{stress \ \sigma = 264.6 \ Mpa}

Explanation:

From the concept of Hooke's  Law,

E =\dfrac{ stress \ \sigma}{ strain \  \varepsilon}

where;

strain \ \varepsilon = \dfrac{change \ in \ dimension }{original \ dimension}

strain \ \varepsilon = \dfrac{7 \ mm }{4.75 \times 10^{3} \ mm}

strain \ \varepsilon =0.00147368

Recall:

E =\dfrac{ stress \ \sigma}{ strain \  \varepsilon}

stress \ \sigma = E \times { strain \  \varepsilon}

stress \ \sigma = 180 \times 10^{3} \ Mpa \times 0.00147

\mathbf{stress \ \sigma = 264.6 \ Mpa}

Thus, the stress in the pipe at the maximum allowable contraction = 264.6 Mpa

7 0
3 years ago
FRIDAY<br> What does a lockbar do?
IrinaK [193]

Answer:

it increases the life of a frame lock

Explanation:

because it decreases wear on the lock face

6 0
2 years ago
Read 2 more answers
Other questions:
  • Suppose that the president of a small island nation has decided to increase government spending by constructing three beach reso
    11·1 answer
  • WHAT IS THE BEST ADVICE FOR SENDING EMAILS? *
    5·1 answer
  • You just purchased a 400-L rigid tank for a client who works in the gas industry. The tank is delivered pre-filled with 3 kg of
    8·1 answer
  • 8. Air at 25C, 100 kPa and air at 50C, 200 kPa at 1 to 1 volume ratio are mixed inside an adiabatic compressor to 55C, 500 kPa a
    15·1 answer
  • Technician A says a limited slip differential can redirect power from a drive wheel that is slipping to the wheel that has tract
    15·1 answer
  • A fiberglass composite is composed of a matrix of vinyl ester and reinforcing fibers of E-glass. The volume fraction of E-glass
    10·1 answer
  • Can someone please do this for me ive been sick for the past week and am behind
    6·1 answer
  • What is the name for a program based on the way your brain works?
    13·2 answers
  • Which of these drum brake systems uses servo action in both directions?
    9·1 answer
  • The product of two factors is 4,500. If one of the factors is 90, which is the other factor?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!