Question

In: Computer Science

This question has been answered before. I need a new, slightly modified code for the following:...

This question has been answered before. I need a new, slightly modified code for the following:

A palindrome is a word that it reads the same left to right and right to left. For this programming assignment, you need to write a C++ program that does the following:

  • Request the user to enter a string.
  • Write a recursive function that will test the string to validate if it is a palindrome or not.
  • Respond back with an output saying if the original string was a palindrome or not.

Please provide new code along with screenshot of output.

Solutions

Expert Solution

code:

#include <bits/stdc++.h>
using namespace std;
bool checkingPalin(char str[],int s,int e){ //checking function
   if (s==e)
   return true;
   if (str[s]!=str[e]) //checking first and last charecters
   return false;
   if (s<e+1) //checking middle charecter
   return checkingPalin(str,s+1,e-1); //calling by itself function
return true;
}
bool isPalindrome(char s[]){ //Palindrome function
   int n = strlen(s); //initiazing the variable with string length
   if (n == 0)
       return true;
   return checkingPalin(s,0,n-1); //returing the checking function
}

int main(){   
   char s[40];   
cin>>s; //taking string from the user
   if (isPalindrome(s)) //calling function
   cout<<"Given string is Palindrome";
   else
   cout<<"Given string is not a Palindrome";
}


Related Solutions

**New code needed! Please do not reference code that has already been answered for this question...
**New code needed! Please do not reference code that has already been answered for this question as that code contains errors*** Write a C++ program to simulate a service desk. This service desk should be able to service customers that can have one of three different priorities (high, medium, and low). The duration for any customer is a random number (between 5 minutes and 8 minutes). You need to write a program that will do the following: Generate random 100...
The whole question has been posted below, but I have answered some of them. I need...
The whole question has been posted below, but I have answered some of them. I need help with questions B, E, and F. I need the critical value in question B. I need the answers for the differences in question E. I need the answers for test statistics in F. Thank you. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- Answer the one-way ANOVA questions using the data below. Use α = 0.01. 1 2 3 4 53 49 47 42 48 34 44 44 39 36...
For this question, you need to implement Java code for the following Modified Ciphertext encryption and...
For this question, you need to implement Java code for the following Modified Ciphertext encryption and attack for known patterns to find the code. Please read the modified Ciphertext carefully and examples before implementing them.   Modified Ciphertext is working as follows: If a plain text (only letters ignore uppercase or lowercase) and sequences of numbers are given, it encrypts the given plain text by shifting each letter in a message the characters based on the given numbers one forward direction...
I please need assistance with the following question " of this question partially answered: Question: Digital...
I please need assistance with the following question " of this question partially answered: Question: Digital Solutions, Inc., manufactures two component parts for the television industry:  Voltag... What price should Digital Solutions charge for the New Voltage Regulator, and what next steps should Digital Solutions take regarding the New Voltage Regulator? 7) Provide a recommendation given the case facts and your analysis. 8) Pay attention to detail within your answers in terms of spelling, grammar, and formatting.   see the...
This question has already been answered, but there was not as much detail as i needed...
This question has already been answered, but there was not as much detail as i needed to understand what exactly to do and i need to understand it quick... could you please walk me through how to do this, but specifically A and B please plug in all numbers and state where they came from , thank you so much! Calculate the potential in the following cell Pb|Pb2+(1.00M)|| Ag+(1.00M) |Ag a. right at the beginning when you start using this...
Please answer with a new answer not one that has already been answered on here before....
Please answer with a new answer not one that has already been answered on here before. Many supervisors are not well-trained on the difficult task of terminating an employee and instead resort to other methods of forcing someone out of the organization. Methods include giving the employee unpleasant work tasks, reducing their hours, or modifying their jobs in some negative way. What are the ethical issues raised by this strategy and what are the risks to the organization?
For the state of New Mexico and Colorado, I need the following questions answered please: a)...
For the state of New Mexico and Colorado, I need the following questions answered please: a) To what extent does New Mexico and Colorado follow the rulings of the Multistate Tax Commission? b) Does New Mexico and Colorado adopt pertinent changes to the Internal Revenue Code? If so, as of what date? c) Is the tax effectiveness of a passive investment company limited in some way? Has New Mexico and Colorado adopted the Geoffrey approach to the taxation of income...
I posted this question before and the person who answered it answered wrong.........please have someone else...
I posted this question before and the person who answered it answered wrong.........please have someone else try again The following information applies to the questions displayed below.] O’Brien Company manufactures and sells one product. The following information pertains to each of the company’s first three years of operations: Variable costs per unit: Manufacturing: Direct materials $28 Direct labor $15 Variable manufacturing overhead $5 Variable selling and administrative $3 Fixed costs per year: Fixed manufacturing overhead $580,000 Fixed selling and administrative...
******I KNOW THIS QUESTION HAS ALREADY BEEN ANSWERED; HOWEVER I WOULD LIKE A DIFFERENT ANSWER***** With...
******I KNOW THIS QUESTION HAS ALREADY BEEN ANSWERED; HOWEVER I WOULD LIKE A DIFFERENT ANSWER***** With the aid of supply and demand diagrams, explain how each of the following would likely affect the prices and quantities of cigarettes sold in the US. (a) A cure is found for lung cancer. (b) There is a substantial increase in wages in tobacco growing states. (c) A fertilizer that increases the yield per acre of tobacco is discovered. (d) There is a substantial...
Please answer Question 2 only. Question 1 has been answered, but need to compare answers from...
Please answer Question 2 only. Question 1 has been answered, but need to compare answers from Question 2 with Question 1. Child-abuse victims and developing cancer: Truth or myth? Is physical childhood abuse somehow related to the development of cancer later in life? A recent survey revealed that people who have been physically abused as children were 49% more likely to develop cancer as adults. ------------------------------------------------------------------- 1. Suppose in a region in Saskatchewan, among a group of 20 adults with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT