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
Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d
Rudik [331]

Answer:

import java.io.*;

public class Main {

   public static void main(String[] args) throws IOException {

       double baseLength = 0, baseWidth = 0, pyramidHeight = 0;

       Object[] volume;

       volume = calcPyramidVolume(baseLength, baseWidth, pyramidHeight);

   }

   public static Object[] calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight) {

       double area = calcBaseArea(baseLength, baseWidth);

       double volume = baseLength * baseWidth * pyramidHeight;

       return new Object[]{volume, area};

   }

   public static double calcBaseArea(double length, double width) {

       return length * width;

   }

}

Explanation:

The problem is flawed because it is completely inefficient for one to create two separate methods to calculate the volume and the area when they can be done at once.

The second problem is that it was never specified whether to return something from the calcBaseArea method.

I assumed it required it, so it is not advisable to initiate the method as a double, but rather create it as an Object so that it can return two values: the volume and the area.

6 0
3 years ago
Multicurrency: There are several products that universal containers sells exclusively in Europe and the UK. Opportunities for th
ivanzaharov [21]

Answer:

D – Create a new validation rule that allows only EUR or GBP to be selected from all active currencies when an opportunity is created for these products.

Explanation:

Application containers are used to hold applications deployed to the internet during production. These containers are products of online hosting cloud services, used to control and maintain the application in production.

Access to the application's functionalities requires validation, the user must be authenticated and authorized to access certain services of the application.

5 0
3 years ago
What method can be used to determine if an email link is authentic?
Sloan [31]
A password and pin hope this helps :D
3 0
3 years ago
A _____ is a form of Web conferencing that uses streaming media technologies to broadcast video and/or audio over the Internet f
ra1l [238]

Answer:

Webcast

Explanation:

Webcast is the live broadcast of a video or audio feed from your event or conference harnessing the internet. Webcast is a media presentation of an event circulated over the internet by using media technology to distribute a single source to various viewers.

Generally,  webcast is briefly defined as broadcasting over the internet. The broadcast might not be specifically live  . One can capture the video or the audio he or she wants to publish and publish it online anywhere. Webcast allow your viewers to remain engage as if they are face to face with the broadcaster.

Webcasting is a a great tools that has been used by various multinational and company to reach wide range of audience . This web based broadcast can even provide opportunity for audience to ask question and even provide answers in real time.

4 0
3 years ago
Read 2 more answers
Where could cloud computing fit in the organizational structure and operations?
vampirchik [111]

Answer:

Computing cloud could fit in the website under the IT directory, with total access to all employees and shareholders.

Explanation:

8 0
3 years ago
Other questions:
  • What type of computer would integrate the system unit with the display and keyboard?
    7·1 answer
  • The tax calculator program of the case study outputs a floating-point number that might show more than two digits of precision.
    7·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
  • A major difference between digital librarians and traditional librarians is that traditional librarians rarely work with people.
    15·2 answers
  • Machine-to-machine (M2M) technology enables sensor-embedded products to share reliable real-time data ________.Select one:a. ove
    14·1 answer
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    11·1 answer
  • Which feature allows you to copy attributes of
    11·1 answer
  • Mention and explain various alignment options​
    9·1 answer
  • What refers to a set of instructions executed in order?
    6·1 answer
  • Why are men more exposed to mass media?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!