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
evablogger [386]
2 years ago
11

A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Ab

le was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a bool function that uses recursion to determine if a string argument is a palindrome. The function should return true if the argument reads the same forward and backward. Demonstrate the function in a program.
Computers and Technology
1 answer:
Pavlova-9 [17]2 years ago
5 0

Answer:

Following are the program in the C++ Programming Language.

//header file

#include <iostream>

//header file for string

#include <string>

#include<cstring>

//using namespace

using namespace std;

//define Function to checks the string is passed is a Palindrome or not

bool is_Palin(string strng, int start_Position, int end_Position)

{

//set the if Conditional statement

if(start_Position >= end_Position)

{

return true;

}

//Check if the character is not the alphabet

if(!isalpha(strng[start_Position]))

{

//Update the starting position  

start_Position += 1;

//call Recursive function

return is_Palin(strng, start_Position++, end_Position);

}

//Check if the character is not the alphabet

if(!isalpha(strng[end_Position]))

{

//Update the end position

end_Position -= 1;

//call Recursive function

return is_Palin(strng, start_Position, end_Position--);

}

//Check if the characters are same or not same

if(tolower(strng[start_Position]) != tolower(strng[end_Position]))

{

return false;

}

//Update the positions

start_Position = start_Position + 1;

end_Position = end_Position - 1;

//call Recursive function

return is_Palin(strng, start_Position, end_Position);

}

//define Main function

int main()

{

string strng;

//get string from the user

cout << "\n\n Enter a string: ";

getline(cin, strng);

//Check for the palindrome

if(is_Palin(strng, 0, strlen(strng.c_str())-1))

{

 //then print message

cout << "\n Is a Palindrome!!!! \n";

}

//otherwise

else

{

//then print message

cout << "\n Is not a Palindrome!!!! \n";

}

return 0;

}

<u>Output:</u>

Enter a string:  Able was I, ere I saw Elba

Is a Palindrome!!!!

Explanation:

Here, we define a boolean data type function "is_Palin" to check the string which passed through is palindrome or not and pass and pass two integer type arguments for starting position and ending position and pass one string data type argument to pass string, inside the function.

  • Set the if conditional statement to check the condition if the start_position of the string is greater than end _position of the string then return true.
  • Set the if conditional statement to check the condition the start_position of the staring is alphabet then, update the start_position and call the recursion function.
  • Again set the if conditional statement to check the condition the end_position of the staring is alphabet then, update the end_position and call the recursion function.
  • Set the if conditional statement to check the condition if the start_position of the string is not equal to the end _position of the string then, return false.
  • Then, update the start_position and end _position of the string increment by 1 then, call the recursive function and then, close the function.

Finally, we define the main function and pass string through calling and passing and argument list in its parameter.  

You might be interested in
Which of the following type of software application would open a txt file
kogti [31]
I think that it's A or C
3 0
2 years ago
Read 2 more answers
What do you need to do in order get paid for ads running on your content?
OverLord2011 [107]
If you're talking about YouTube or platforms like that, you have to monetize your videos in the settings. However, if your video contains copyrighted content, you will most likely be banned or given a strike for copyright infringement. You can monetize videos that have absolutely no copyrighted music, pictures or videos
4 0
3 years ago
Six causes of data lost
Serhud [2]
Hard drive failures

Accidental deletions

Computer viruses and malware infections



Power failures
6 0
3 years ago
A(n) __________is an output device that enable a machine operator to view the acc or pre vlaue of an insstruction without the us
antoniya [11.8K]

A <u>LED display</u> is an output device that enable a machine operator to view the acc or pre vlaue of an insstruction without the use of a programming terminal

<h3>What is LED display device?</h3>

LED Display (light-emitting diode display) is a screen display technology that uses a panel of LEDs as the light source. Currently, a large number of electronic devices, both small and large, use LED display as a screen and as an interaction medium between the user and the system.

<h3>Where is LED display used?</h3>

An LED (Light-Emitting Diode) is a small cell or conductor that glows and becomes illuminated when a voltage is applied to it. The phrase 'LED display' is often used broadly to describe screens on a wide range of devices. This includes commercial and consumer technology such as TVs, mobile phones, and PC monitors.

To learn more about LED Display , refer

brainly.com/question/17019750

#SPJ4

8 0
1 year ago
Question 5 a remote access server is typically implemented on a server class operating system, such as windows server 2008 r2 ru
Reika [66]
Answer: <span>Routing & </span>Remote Access<span> (RRAS)</span>
7 0
2 years ago
Other questions:
  • Which type of cable is described as a central conductor wire that is surrounded by insulating materials and placed inside a brai
    13·1 answer
  • Technician A says that wheel speed sensors are a highly probable cause of illuminated EBC warning lamps. Technician B says that
    10·1 answer
  • The hexadecimal number system uses alphabets A to F to represent values_ to _
    12·2 answers
  • True/False: Audio menus can be useful when one's hands and eyes are busy, or to assist vision-impaired users. With audio menus,
    14·1 answer
  • Describe a situation in which you have experienced harm as a consequence of a failure of computer security. Was the failure mali
    6·1 answer
  • Different network scenarios require the
    9·1 answer
  • Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point
    12·1 answer
  • Cuales son las paginas web​
    12·1 answer
  • Question 4
    5·1 answer
  • you have been using snmp on your network for monitoring and management. you are concerned about the security of this configurati
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!