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]
2 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]2 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
Compare electromagnets and solenoids
natta225 [31]

An electromagnet is a made coil associated with a ferromagnetic core. This way, the strength of the magnet is controlled by the input current. A solenoid is a simple shape used in magnetostatics or magnetics. ... A solenoid is a cylindrical coil of wire whose diameter is small compared to its length.

8 0
3 years ago
Consider two Carnot heat engines operating in series. The first engine receives heat from the reservoir at 1400 K and rejects th
Aleksandr-060686 [28]

Answer:

The temperature T= 648.07k

Explanation:

T1=input temperature of the first heat engine =1400k

T=output temperature of the first heat engine and input temperature of the second heat engine= unknown

T3=output temperature of the second heat engine=300k

but carnot efficiency of heat engine =1 - \frac{Tl}{Th} \\

where Th =temperature at which the heat enters the engine

Tl is the  temperature of the environment

since both engines have the same thermal capacities <em>n_{th} </em> therefore n_{th} =n_{th1} =n_{th2}\\n_{th }=1-\frac{T1}{T}=1-\frac{T}{T3}\\ \\= 1-\frac{1400}{T}=1-\frac{T}{300}\\

We have now that

\frac{-1400}{T}+\frac{T}{300}=0\\

multiplying through by T

-1400 + \frac{T^{2} }{300}=0\\

multiplying through by 300

-420000+ T^{2} =0\\T^2 =420000\\\sqrt{T2}=\sqrt{420000}  \\T=648.07k

The temperature T= 648.07k

5 0
3 years ago
Four of the minterms of the completely specified function f(a, b, c, d) are m0, m1, m4, and m5.
Sveta_85 [38]

Complete Question

The complete question is shown on the first uploaded image

Answer:

a) The required additional minterms  for f so that f has eight primary implicants with two literals and no other prime implicant are m_{2},m_{3},m_{7},m_{8},m_{11},m_{12},m_{13},m_{14} and m_{15}

b) The essential prime implicant are c' d',a'b',ab and cd

c) The minimum sum-of-product expression for f are

                  a'b' +ab +c'd'+cd+a'c',\\ a'b'+ab+c'd'+cd+a'd,\\a'b'+ab+c'd'+cd+bc'  and  \\ a'b'+ab+c'd' +cd+bd

Explanation:

The explanation is shown on the second third and fourth image

8 0
2 years ago
You are to design two CONCEPTUALLY different synchronous state machines (Mealy and Moore) that perform the task described below.
allochka39001 [22]
Answer:








Explanation:









I hope this helps!
3 0
3 years ago
Energy transfer in mechanical systems: During steady-state operation, a mechanical gearbox receives 70 KW of input power through
Degger [83]

Answer:

Heat transfer rate(Q)= 1.197kW

Power output(W)=68.803kW

3 0
2 years ago
Other questions:
  • The head difference between the inlet and outlet of a 1km long pipe discharging 0.1 m^3/s of water is 0.53 m. If the diameter is
    11·1 answer
  • Water at 20 °C is flowing with velocity of 0.5 m/s between two parallel flat plates placed 1 cm apart. Determine the distances f
    5·1 answer
  • A belt/pulley system has tight side of 1000N, a slack side of 100N and a wrap angle of 500 degrees. The belt is just on the poin
    5·1 answer
  • If d=0.25m and D=0.40m. Assume headloss from the contraction to the end of the pipe can be found as hų = 0.9 (V is velocity in t
    8·1 answer
  • Multiple Choice
    10·1 answer
  • Calculate the number of vacancies per cubic meter at 1000∘C for a metal that has an energy for vacancy formation of 1.22 eV/atom
    14·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
  • Discuss in detail the manners of interaction with opposite gender
    10·1 answer
  • For two different air velocities, the Nusselt number for two different diameter cylinders in cross flow is the same. The average
    6·1 answer
  • How much energy in joule is added to a 12 g of sample of aluminum (c=0.897 J/g ◦C) to raise the temperature from 20 ◦C to 45 ◦C?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!