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]
3 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]3 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
Write a method that determines the total number of chars in each string of an array.
Serjik [45]
The total number of chars in each string is basically the size of each string.

Using JAVA:

        String[] arr = {"hello", "my", "name", "is", "Felicia"};                int count = 0;        for(int i = 0; i < arr.length; i++) {            count = count + arr[i].length();            System.out.println("Characters in " + arr[i] + ": " + count);        }

Output: 
<span>Characters in hello: 5
Characters in my: 7
Characters in name: 11
Characters in is: 13
Characters in Felicia: 20</span>


8 0
3 years ago
Which statement is true of Web-based social media?
Nataliya [291]
I think the answer is A.
6 0
3 years ago
How are modern computers different from eniac?
Natalka [10]
Modern computers use in side a memory board to store info but back then you would use flappy disks   
8 0
3 years ago
A downloaded executable file may contain harmful software known as
mylen [45]

Answer:

A downloaded executable file may contain harmful software know as malware.

Further details:

Malwares:

Malware (a portmanteau for pernicious programming) is any product purposefully intended to make harm a PC, server, customer, or PC network. Malware does the harm after it is embedded or brought somehow or another into an objective's PC and can appear as legitimately executable code, contents, supposed "dynamic substance" (Microsoft Windows), and different types of data. Some sorts of malware are to a great extent alluded to in the media as PC infections, worms, Trojan steeds, ransomware, spyware, adware, and scareware, among different terms. Malware has a malignant expectation, acting against the enthusiasm of the PC client—thus does exclude programming that causes accidental damage because of some lack, which is regularly portrayed as a product bug.

Uses:

Malware is once in a while utilized comprehensively against government or corporate sites to assemble monitored information, or to upset their activity as a rule. However, malware can be utilized against people to pick up data, for example, individual recognizable proof numbers or subtleties, bank or charge card numbers, and passwords.

Answer details:

Subject: Computer and technology

Level: College

Keywords:

• Harmful software

• Malware

• Malware software

• Uses of malware

• Purpose of malware

Learn more to evaluate:

brainly.com/question/4997492

brainly.com/question/4010464

brainly.com/question/1754173

8 0
3 years ago
Read 2 more answers
I need help with this problem please
alina1380 [7]

Answer:

i think its d

8 0
3 years ago
Other questions:
  • Which ofthe following is the most correct statement about the interestsection of the indirect plan for persuasion?
    8·1 answer
  • Using a cell phone while operating a motor vehicle is considered distraction because
    8·1 answer
  • What is an activity that can help you enhance the appearance of your computer’s desktop?
    13·1 answer
  • You start up your laptop while getting a coffee across the room. You hear the usual chimes and doinks as it starts up. When you
    14·2 answers
  • What is the decimal value of 00001111
    14·1 answer
  • What do level meters show?
    8·1 answer
  • What are the advantages and disadvantages of the various collision resolution strategies for hashes?
    7·2 answers
  • A university with remote campuses, which all use different service providers, loses Internet connectivity across all locations.
    12·1 answer
  • What is the difference between MySQL and MariaDB?
    9·1 answer
  • You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you re
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!