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
Five kg of water is contained in a piston-cylinder assembly, initially at 5 bar and 240°C. The water is slowly heated at constan
Digiron [165]

Answer:

The final temperature of water is 381.39  °C.

Explanation:

Given that

Mass of water = 5 kg

Heat transfer at constant pressure Q = 2960 KJ

Initial temperature = 240 °C

We know that heat transfer at constant pressure given as follows

Q=mC_p\Delta T

We know that for water

C_p=4.187\ \frac{KJ}{kg.K}

Lets take final temperature of water is T

So

Q=mC_p\Delta T

2960=5\times 4.187(T-240)

T=381.39  °C

So the final temperature of water is 381.39  °C.

7 0
3 years ago
A heat engine that receives heat from a furnace at 1200°C and rejects waste heat to a river at 20°C has a thermal efficiency of
viktelen [127]

Answer:

second-law efficiency  = 62.42 %

Explanation:

given data

temperature T1 = 1200°C = 1473 K

temperature T2 = 20°C  =  293 K

thermal efficiency η = 50 percent

solution

as we know that thermal efficiency of reversible heat engine between same  temp reservoir

so here

efficiency ( reversible ) η1 = 1 - \frac{T2}{T1}      ............1

efficiency ( reversible ) η1  = 1 - \frac{293}{1473}  

so efficiency ( reversible ) η1  = 0.801

so here second-law efficiency of this power plant is

second-law efficiency = \frac{thernal\ efficiency}{0.801}

second-law efficiency = \frac{50}{0.801}  

second-law efficiency  = 62.42 %

3 0
3 years ago
W²-5w+14
alexira [117]

Answer:w²-5w+14

4x²+11x+16

6x²+7x-10

x²-16x+56

Explanation:

7 0
3 years ago
Select the statement that is false.
ra1l [238]

Answer:

D

Explanation:

the way vertices are connected may be different so having same number of edges do not mean that total degree will also be same.

8 0
3 years ago
1. (5 pts) An adiabatic steam turbine operating reversibly in a powerplant receives 5 kg/s steam at 3000 kPa, 500 °C. Twenty per
KiRa [710]

Answer:

temperature of first extraction 330.8°C

temperature of second extraction 140.8°C

power output=3168Kw

Explanation:

Hello!

To solve this problem we must use the following steps.

1. We will call 1 the water vapor inlet, 2 the first extraction at 100kPa and 3 the second extraction at 200kPa

2. We use the continuity equation that states that the mass flow that enters must equal the two mass flows that leave

m1=m2+m3

As the problem says, 20% of the flow represents the first extraction for which 5 * 20% = 1kg / s

solving

5=1+m3

m3=4kg/s

3.

we find the enthalpies and temeperatures in each of the states, using thermodynamic tables

Through laboratory tests, thermodynamic tables were developed, these allow to know all the thermodynamic properties of a substance (entropy, enthalpy, pressure, specific volume, internal energy etc ..)  

through prior knowledge of two other properties

4.we find the enthalpy and entropy of state 1 using pressure and temperature

h1=Enthalpy(Water;T=T1;P=P1)

h1=3457KJ/kg

s1=Entropy(Water;T=T1;P=P1)

s1=7.234KJ/kg

4.

remembering that it is a reversible process we find the enthalpy and the temperature in the first extraction with the pressure 1000 kPa and the entropy of state 1

h2=Enthalpy(Water;s=s1;P=P2)

h2=3116KJ/kg

T2=Temperature(Water;P=P2;s=s1)

T2=330.8°C

5.we find the enthalpy and the temperature in the second extraction with the pressure 200 kPav y the entropy of state 1

h3=Enthalpy(Water;s=s1;P=P3)

h3=2750KJ/kg

T3=Temperature(Water;P=P3;s=s1)

T3=140.8°C

6.

Finally, to find the power of the turbine, we must use the first law of thermodynamics that states that the energy that enters is the same that must come out.

For this case, the turbine uses a mass flow of 5kg / s until the first extraction, and then uses a mass flow of 4kg / s for the second extraction, taking into account the above we infer the following equation

W=m1(h1-h2)+m3(h2-h3)

W=5(3457-3116)+4(3116-2750)=3168Kw

7 0
3 years ago
Other questions:
  • One-dimensional, steady-state conduction with uniform internal energy generation occurs in a plane wall with a thickness of 50 m
    14·1 answer
  • Given the following MATLAB statement: ( 3 + 2 ) / 5 * 4 + 5 ^ 2 In what order will these operations be done?
    9·1 answer
  • A soil has the following Green-Ampt parameters Effective porosity 0.400 Initial volumetric moisture content-15% Hydraulic Conduc
    6·1 answer
  • Which of the following has nothing to do with insulating glass? Group of answer choices
    10·2 answers
  • Plz answer all of these questions!
    15·1 answer
  • In a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their
    8·1 answer
  • 1. Springs____________<br> energy when compressed<br> And _________energy when they rebound.
    12·1 answer
  • 1. Using the formula above, complete this task.
    9·1 answer
  • Technician A that shielding gas nozzles may have different shapes. Technician B says that gelding gas nozzles is attached to the
    8·1 answer
  • How does energy transition from one form to another as water moves from behind a dam to downstream of a dam?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!