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]
2 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:
defon2 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
Velocity components in an incompressible flow are: v = 3xy + x^2 y: w = 0. Determine the velocity component in the x-direction.
cupoosta [38]

Answer:

Velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

Explanation:

   v=3xy+x^{2}y

We know that for incompressible flow

   \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}=0

\frac{\partial v}{\partial y}=3x+x^{2}

So   \frac{\partial u}{\partial x}+3x+x^{2}=0

\frac{\partial u}{\partial x}= -3x-x^{2}

By integrate with respect to x,we will find

u=-\frac{3}{2}x^2-\frac{1}{3}x^3+C

So the velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

3 0
3 years ago
Imagine the reaction A + B LaTeX: \Longleftrightarrow⟺ C + D proceeds at room temperature (25 °C) and is determined to have a re
Wittaler [7]

Answer:

0.2 kcal/mol is the value of \Delta G for this reaction.

Explanation:

The formula used for is:

\Delta G_{rxn}=\Delta G^o+RT\ln Q

\Delta G^o=-RT\ln K

where,

\Delta G_{rxn} = Gibbs free energy for the reaction

\Delta G_^o =  standard Gibbs free energy  

R =Universal  gas constant

T = temperature

Q = reaction quotient

k = Equilibrium constant

We have :

Reaction quotient of the reaction = Q = 46

Equilibrium constant of reaction = K = 35

Temperature of reaction = T = 25°C = 25 + 273 K = 298 K

R = 1.987 cal/K mol

\Delta G_{rxn}=-RT\ln K+RT\ln Q

=-1.987 cal/K mol\times 298 K\ln [35]+1.987 cal/K mol\times 298K\times \ln [46]

=-2,105.21 cal/mol+2,267.04 cal/mol=161.82 cal/mol=0.16182 kcal/mol\approx 0.2 kcal/mol

1 cal = 0.001 kcal

0.2 kcal/mol is the value of \Delta G for this reaction.

5 0
3 years ago
9. A box contains (4) red balls, and (7) white balls ,we draw( two) balls with return , find 1. Show the sample space &amp; n(s)
zzz [600]

Answer:

The answers to your questions are given below.

Explanation:

The following data were obtained from the question:

Red (R) = 4

White (W) = 7

1. Determination of the sample space, S.

The box contains 4 red balls and 7 white balls. Therefore, the sample space (S) can be written as follow:

S = {R, R, R, R, W, W, W, W, W, W, W}

nS = 11

2. Determination of the probability of all results that appeared in the sample space.

From the question, we were told that the two balls was drawn with return. There, the probability of all results that appeared in the sample space can be given as follow:

i. Probability that the first draw is red and the second is also red.

P(R1) = nR/nS

Red (R) = 4

Space space (S) = 11

P(R1) = nR/nS

P(R1) = 4/11

P(R2) = nR/nS

P(R2) = 4/11

P(R1R2) = P(R1) x P(R2)

P(R1R2) = 4/11 x 4/11

P(R1R2) = 16/121

Therefore, the Probability that the first draw is red and the second is also red is 16/121.

ii. Probability that the first draw is red and the second is white.

Red (R) = 4

White (W) = 7

Space space (S) = 11

P(R) = nR/nS

P(R) = 4/11

P(W) = nW/nS

P(W) = 7/11

P(RW) = P(R) x P(W)

P(RW) = 4/11 x 7/11

P(RW) = 28/121

Therefore, the probability that the first draw is red and the second is white is 28/121.

iii. Probability that the first draw is white and the second is also white.

White (W) = 7

Space space (S) = 11

P(W1) = nW/nS

P(W1) = 7/11

P(W2) = nW/n/S

P(W2) = 7/11

P(W1W2) = P(W1) x P(W2)

P(W1W2) = 7/11 x 7/11

P(W1W2) = 49/121

Therefore, the probability that the first draw is white and the second is also white is 49/121.

iv. Probability that the first draw is white and the second is red.

Red (R) = 4

White (W) = 7

Space space (S) = 11

P(W) = nW/nS

P(W) = 7/11

P(R) = nR/nS

P(R) = 4/11

P(WR) = P(W) x P(R)

P(WR) = 7/11 x 4/11

P(WR) = 28/121

Therefore, the probability that the first draw is white and the second is red is 28/121.

7 0
3 years ago
When is the output of an XOR gate HIGH? explain​
erma4kov [3.2K]

Answer:

The output of a NOR gate is LOW whenever one or more inputs are HIGH. The output of an XOR gate is HIGH whenever the two inputs are different. The output of an XNOR gate is HIGH whenever the two inputs are identical

5 0
2 years ago
A hypothetical accumulator processor uses one of the following 16-bit instruction formats, depending on the instruction.(a) (10
Jlenok [28]

Answer:

Every part has been answered with complete detail. See the pictures.

Explanation:

See the pictures for detailed answer.

7 0
3 years ago
Other questions:
  • - if `check_1` and `check_2` variables are both True, it should set the value of a variable `outcome` to the string 'BOTH' - eli
    12·1 answer
  • What is the heat flux (W/m2) to an object when subjected to convection heat transfer environment given: 24 °C = the surface temp
    10·1 answer
  • Tech a says that the weight of the flywheel smoothest out the engines power pulses. Tech B says that the flexplate and torque co
    10·1 answer
  • A 2-m3 rigid tank initially contains air at 100 kPa and 22°C. The tank is connected to a supply line through a valve. Air is flo
    14·1 answer
  • How do you make a 3d print
    6·1 answer
  • Demonstreaza in 20 de propoziti ca snoava pacala si zarzarele boerului e o snoava
    12·1 answer
  • Which should i get they are both for sale
    10·2 answers
  • A shunt regulator utilizing a zener diode with an incremental resistance of 8 ohm is fed through an 82-Ohm resistor. If the raw
    6·1 answer
  • Chad is working on a design that uses the pressure of steam to control a valve in order to increase water pressure in showers. W
    5·1 answer
  • Saferty precautions of drill press​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!