Question

In: Computer Science

This is C++, please insert screenshot of output please. Part1: Palindrome detector Write a program that...

This is C++, please insert screenshot of output please.

Part1: Palindrome detector

Write a program that will test if some string is a palindrome

  1. Ask the user to enter a string
  2. Pass the string to a Boolean function that uses recursion to determine if something is a palindrome or not. The function should return true if the string is a palindrome and false if the string is not a palindrome.
  3. Main displays the result ( if the string is a palindrome or not

Solutions

Expert Solution

#include <iostream>

using namespace std;

bool palindromeWhile(string s, int size)

{

bool status = false;

int i = 0 , j = size - 1;

while( i <= j)

{

if(s[i] == s[j])

{

status = true;

}

else

{

return false;

}

j--;

++i;

}

return status;

}

int main()

{

const int SIZE = 100;

string inputString;

char str[SIZE], again;

int size;

do

{

cout<<"Enter a string: ";

getline(cin,inputString);

if (palindromeWhile(inputString, inputString.size()))

cout << inputString << " is a palindrome.\n";

else

cout << inputString << " is not a palindrome.\n";

cout << "Try another string? (Y/N) ";

cin >> again;

cin.ignore();

} while (again == 'Y' || again == 'y');

system("pause");

}

==================================================================
SEE OUTPUT

========================================
Thanks, let me now if there is any concern.


Related Solutions

# please answer question asap please Write a program in C to insert new value in...
# please answer question asap please Write a program in C to insert new value in the array (unsorted list). Use pointer notation for the array elements .Test Data:Input the size of array: 4 Input 4 elements in the array in ascending order: element -0: 2 element -1: 9 element -2: 7 element -3: 12 Input the value to be inserted: 5 Input the Position, where the value to be inserted: 2 Expected Output:The current list of the array:2 9...
PLEASE do the following problem in C++ with the screenshot of the output. THANKS! Assuming that...
PLEASE do the following problem in C++ with the screenshot of the output. THANKS! Assuming that a text file named FIRST.TXT contains some text written into it, write a class and a method named vowelwords(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel (i.e., with 'a', 'e', 'i', 'o', 'u'). For example, if the file FIRST.TXT contains Carry umbrella and overcoat...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array Program 2 Implement a tree using linked list - pointer Binary Tree Program 3 - Convert program 1 to a template
Part1: Write a program in C/C++ to find the maximum flow in the given Flow Network...
Part1: Write a program in C/C++ to find the maximum flow in the given Flow Network using (i)Ford -Fulkerson algorithm and (ii) Edmond-Karps algorithm Go through the related text and implement each of these algorithms using the efficient data structure. Show the results of different steps of these algorithms for an instance of the flow network with total number of nodesV=6 (please note down that in a flow network there are two special nodes source and sink) and total number...
Part 1 (Objective C++ and please have output screenshot) The purpose of this part of the...
Part 1 (Objective C++ and please have output screenshot) The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class. The class will have the following data members: A string for the name of the author A string for the book title A long integer for the ISBN The class will have the following...
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible,...
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible, please provide info from .txt files created** You are to write a program which is going to use inheritance. It should start off with the base classes Account: contains the string name, int accountnumber, double balance. Savings: Derived from Account class, it should contain double interest rate. Checkings: Derived from Account class, it should contain double overdraftlimit. CreditCard: Derived from Checkings class, it should...
please using Repl.it basic C-programing part1 Write a program that requests 5 integers from the user...
please using Repl.it basic C-programing part1 Write a program that requests 5 integers from the user and stores them in an array. You may do this with either a for loop OR by getting a string from stdin and using sscanf to store formatted input in each spot in the array. part2 Add a function to the program, called get_mean that determines the mean, which is the average of the values. The function should be passed the array and the...
Please in C++ thank you! Please also include the screenshot of the output. I have included...
Please in C++ thank you! Please also include the screenshot of the output. I have included everything that's needed for this. Pls and thank you! Write a simple class and use it in a vector. Begin by writing a Student class. The public section has the following methods: Student::Student() Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0. bool Student::ReadData(istream& in) Data input. The istream should already be open. Reads the following data, in this order:...
write C program to implement the priority queue with the operation insert
write C program to implement the priority queue with the operation insert
Part1: Write a program in C/C++ to solve the 0/1 knapsack problem using (i) Dynamic Programming...
Part1: Write a program in C/C++ to solve the 0/1 knapsack problem using (i) Dynamic Programming based algorithm and (ii) Branch and Bound Search based algorithm Go through the related text and implement each of these algorithms using the efficient data structure. Show the results of different steps of these algorithms for an instance of the 0/1 Knapsack problem with number of items, n=4. The capacity of the knapsack, weights and profits of the items may be generated randomly with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT