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
MakcuM [25]
3 years ago
12

C++A palindrome is a string such as "madam", "radar", "Dad", and "I", that reads the same forwards and backwards. The empty stri

ng is regarded as a palindrome. Wrtie a recursive functionbool isPalindrome(string str, int lower, int upper)that returns true if and only if the part of the string str in positions lower through upper (inclusive at both ends) is a palindrome. Test your function by writting a main function that repeatedly asks the user to enter strings terminated by the ENTER key. These strings are then tested for palindromecity. The program termintaes when the user presses the Enter key without typing any haracters before it.
Engineering
1 answer:
jeka57 [31]3 years ago
5 0

Answer:

See explaination

Explanation:

#include <iostream>

#include<string.h>

using namespace std;

bool isPalindrome(string str, int lower, int upper){

if(str.length() == 0 || lower>=upper){

return true;

}

else{

if(str.at(lower) == str.at(upper)){

return isPalindrome(str,lower+1,upper-1);

}

else{

return false;

}

}

}

int main(){

string input;

cout<<"Enter string: ";

cin>>input;

if(isPalindrome(input,0,input.length()-1)){

cout<<input<<" is a palindrome"<<endl;

}

else{

cout<<input<<" is NOT a palindrome"<<endl;

}

return 0;

}

You might be interested in
A rigid tank contains an ideal gas at 40°C that is being stirred by a paddle wheel. The paddle wheel does 240 kJ of work on the
Sergeu [11.5K]

To solve the problem it is necessary to consider the concepts and formulas related to the change of ideal gas entropy.

By definition the entropy change would be defined as

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{P_2}{P_1})

Using the Boyle equation we have

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{v_1T_2}{v_2T_1})

Where,

C_p = Specific heat at constant pressure

T_1= Initial temperature of gas

T_2= Final temprature of gas

R = Universal gas constant

v_1= Initial specific Volume of gas

v_2= Final specific volume of gas

According to the statement, it is an isothermal process and the tank is therefore rigid

T_1 = T_2, v_2=v_1

The equation would turn out as

\Delta S = C_p ln1-ln1

<em>Therefore the entropy change of the ideal gas is 0</em>

Into the surroundings we have that

\Delta S = \frac{Q}{T}

Where,

Q = Heat Exchange

T = Temperature in the surrounding

Replacing with our values we have that

\Delta S = \frac{230kJ}{(30+273)K}

\Delta S = 0.76 kJ/K

<em>Therefore the increase of entropy into the surroundings is 0.76kJ/K</em>

8 0
3 years ago
Motor oil is responsible for
Lelechka [254]

Answer:

lubricating all moving parts in the engine

Explanation:

like the pistons, pushrods, and the crank

5 0
3 years ago
A converging-diverging nozzle has an area ratio of 5.9. (1) Determine the (P0/Pt) values corresponding to the 1st, 2nd, and 3rd
nata0808 [166]

Answer:

Check the explanation

Explanation:

The Total pressure is the overall of fixed or static pressure p, the dynamic pressure q, as well as gravitational head. Total pressure can also be referred to as the measure of the overall energy of the airstream, and is the same to static pressure plus velocity pressure.

kindly check the step by step solution in the attached image below to Determine the (P0/Pt) values corresponding to the 1st, 2nd, and 3rd critical points.

5 0
3 years ago
What is the primary function of NCEES?
charle [14.2K]

Answer:

It is a non profit organization that dedicates to licensing professional engineers and surveyors

Explanation:

6 0
3 years ago
Assuming the transition to turbulence for flow over a flat plate happens at a Reynolds number of 5x105, determine the following
torisob [31]

Given:

Assuming the transition to turbulence for flow over a flat plate happens at a Reynolds number of 5x105, determine the following for air at 300 K and engine oil at 380 K. Assume the free stream velocity is 3 m/s.

To Find:

a. The distance from the leading edge at which the transition will occur.

b. Expressions for the momentum and thermal boundary layer thicknesses as a function of x for a laminar boundary layer

c. Which fluid has a higher heat transfer

Calculation:

The transition from the lamina to turbulent begins when the critical Reynolds

number reaches 5\times 10^5

(a).  \;\text{Rex}_{cr}=5 \times 10^5\\\\\frac{\rho\;vx}{\mu}=5 \times 10^5\\\text{density of of air at}\;300K=1.16  \frac{kg}{m\cdot s}\\\text{viscosity of of air at}\;300K=1.846 \times 10^{-5} \frac{kg}{m\cdot s} \\v=3m/s\\\Rightarrow x=\frac{5\times 10^5 \times 1.846 \times 10^{-5} }{1.16 \times 3} =2.652 \;m \;\text{for air}\\(\text{similarly for engine oil at 380 K for given}\; \rho \;\text{and} \;\mu)\\

(b).\; \text{For the lamina boundary layer momentum boundary layer thickness is given by}:\\\frac{\delta}{x} =\frac{5}{\sqrt{R_e}}\;\;\;\;\quad\text{for}\; R_e(c). \frac{\delta}{\delta_t}={P_r}^{\frac{r}{3}}\\\text{For air} \;P_r \;\text{equivalent 1 hence both momentum and heat dissipate with the same rate for oil}\; \\P_r >>1 \text{heat diffuse very slowly}\\\text{So heat transfer rate will be high for air.}\\\text{Convective heat transfer coefficient will be high for engine oil.}

7 0
3 years ago
Other questions:
  • What are factor of safety for brittle and ductile material
    5·1 answer
  • Required information NOTE: This is a multi-part question. Once an answer is submitted, you will be unable to return to this part
    9·1 answer
  • On a hot summer day, a student turns his fan on when he leaves his room in the morning. When he returns in the evening, will the
    5·1 answer
  • Will this airplane stay in the air a long time? Why or why not?
    9·1 answer
  • Is someone an engineer that can help me?plz
    11·1 answer
  • A turntable A is built into a stage for use in a theatrical production. It is observed during a rehearsal that a trunk B starts
    5·1 answer
  • In order to lift a lighter object on the other side, a boy placed 155 N of
    6·1 answer
  • Scientists use characteristics to compare stars. Match each characteristic on the left with the statement on the right that uses
    15·1 answer
  • Most equipment is cooled by bringing cold air in the front and ducting the heat out of the back. What is the term for where the
    9·1 answer
  • 9. What power tool incorporates a set of dies and punches to cut new
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!