C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 6, Problem 6.31RE
Program Plan Intro
- Include the header files and initialize the main() function.
- Prompt the user to take the input of string from the user.
- To define the recursive function testPalindrome (char[]) to find whether the string is palindrome or not.
- Call the function to display the output.
- Define the function role in the respective function definition.
Program Description- The purpose of the program is to take the string as input and tell if the string is palindrome or not using the following recursive function-
inttestPalindrome (char[])
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a recursive function that computes the sum of the digits in an integer. Use the following function header:
def sumDigits(n):For example, sumDigits(234) returns Write a test program that prompts the user to enter an integer and displays its sum.
Write a recursive function that displays the number of even and odd digits in an integer using the following header:
void evenAndOddCount(int value)
Write a test program that prompts the user to enter an integer and displays the number of even and odd digits in it.
Exponent
y Catherine Arellano
mplement a recursive function that returns
he exponent given the base and the result.
for example, if the base is 2 and the result is
3, then the output should be 3 because the
exponent needed for 2 to become 8 is 3 (i.e.
23 = 8)
nstructions:
1. In the code editor, you are provided
with a main() function that asks the
user for two integer inputs:
1. The first integer is the base
2. The second integer is the result
2. Furthermore, you are provided with the
getExponent() function. The details of
this function are the following:
1. Return type - int
2. Name - getExponent
3. Parameters
1. int - base
2. int - result
4. Description - this recursive function
returns the exponent
5. Your task is to add the base case and
the general case so it will work
Score: 0/5
Overview
1080
main.c
exponent.h
1 #include
2 #include "exponent.h"
3 int main(void) {
4
int base, result;
5
6
printf("Enter the base: ");
scanf("%d", &base);
7
8
9
printf("Enter the result: ");…
Chapter 6 Solutions
C How to Program (8th Edition)
Ch. 6 - Fill in the blanks in each of the following: C...Ch. 6 - State which of the following are true and which...Ch. 6 - Write statements to accomplish each of the...Ch. 6 - Consider a 2-by-5 integer array t. Write a...Ch. 6 - (Sales Commissions) Use a one-dimensional array to...Ch. 6 - (Bubble Sort) The bubble sort presented in Fig....Ch. 6 - Write loops that perform each of the following...Ch. 6 - Prob. 6.13ECh. 6 - (Mean, Median and Mode Program Modifications)...Ch. 6 - (Duplicate Elimination) Use a one-dimensional...
Ch. 6 - Label the elements of 3-by-5 two-dimensional array...Ch. 6 - What does the following program do?Ch. 6 - What does the following program do?Ch. 6 - (Dice Rolling) Write a program that simulates the...Ch. 6 - (Game of Craps) Write a program that runs 1000...Ch. 6 - Prob. 6.21ECh. 6 - (Total Sales) Use a two-dimensional array to solve...Ch. 6 - (Turtle Graphics) The Logo language made the...Ch. 6 - Prob. 6.24ECh. 6 - (Knights Tour: Brute-Force Approaches) In Exercise...Ch. 6 - (Eight Queens) Another puzzler for chess buffs is...Ch. 6 - (Eight Queens: Brute-Force Approaches) In this...Ch. 6 - (Duplicate Elimination) In Chapter 12, we explore...Ch. 6 - (Knights Tour: Closed Tour Test) In the Knights...Ch. 6 - (The Sieve of Eratosthenes) A prime integer is any...Ch. 6 - Prob. 6.31RECh. 6 - (Linear Search) Modify the program of Fig. 6.18 to...Ch. 6 - (Binary Search) Modify the program of Fig. 6.19 to...Ch. 6 - Prob. 6.35RECh. 6 - Prob. 6.36RECh. 6 - Prob. 6.37RE
Knowledge Booster
Similar questions
- Write a recursive function that computes the product of the digits in an integer. Use the following function header: int productDigits(int n) For example, productDigits(912) returns 9 * 1 * 2 = 18. Write a test pro- gram that prompts the user to enter an integer and displays the product of digits.arrow_forwardWrite a recursive function to return the total number of space characters in a string. You need to define the following two functions. The second one is a recursive helper function. int numberOfSpaces(const string& s) int numberOfSpaces(const string& s, int i) Write a test program that prompts the user to enter a string, invokes the function, and displays the number of spaces in the string.arrow_forwardWrite a recursive function that displays a string reversely on the console using the following header: void reverseDisplay(const string& s) For example, reverseDisplay("abcd") displays dcba. Write a test program that prompts the user to enter a string and displays its reversal.arrow_forward
- JAVA CODE ONLY AND PROVIDE OUTPUT SCREENSHOT PLEASEarrow_forwardProblem: Recursive Power Method Design a python function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised, and the exponent. Assume the exponent is a nonnegative integer. Write the main() function to input the required parameters as shown in thesample input/output. Sample Output:Average number of words per line: 26.0Enter a number: 2Enter a positive whole number between 1 and 100: 102.0 raised to the power of 10 is 1,024.00arrow_forwardRecursive Power FunctionWrite a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer. Demonstrate the function in a program. SAMPLE RUN #0: ./recursiveExponent Hide Invisibles Highlight: Show Highlighted Only 2^3=8↵ 2^4=16↵ 3^3=27↵ 6^3=216↵ 7^7=823543↵ 10^9=1000000000↵arrow_forward
- I just need exactly what they are asking me to do. Thank youarrow_forwardRead Chapter 12 Recursive Lines Write a recursive function that accepts an integer argument, n. The function should display n lines of asterisks on the screen, with the first line showing 1 asterisk, the second line showing 2 asterisks, up to the middle line which shows n asterisks. You will then continue to print less stars until your last line of one asterisk. With an input of 3 your output should look like below. You will need to wind the stack to print up to your largest line. You will print the last set of lines as you unwind the stack or as you come out of your recursion. * ** *** ** *arrow_forwardWrite a recursive function that converts a decimal number into a binary number as a string. The function header is: string decimalToBinary(int value) Write a test program that prompts the user to enter a decimal number and dis- plays its binary equivalent.arrow_forward
- 2. Sum: a recursive function that computes the sum of integers 1, 2, 3, …., n for a given number n. So Sum(6) should return 1 + 2 + 3 + 4 + 5 + 6 , i.e. 21.sum(n) = n + sum(n-1)arrow_forwardCodeW X b For func x C Solved X b Answer X https://codeworkou... CodeWorkout X270: Recursion Programming Exercise: Count Characters For function countChr() write the missing part of the recursive call. This function should return the number of times that the letter "A" appears in string "str". Recall that str.substring(a) will return the substring of str from position a to the end of str, while str.substring (a, b) will return the substring of str starting at position a and continuing to (but not including) the character at position b. Examples: countChr ("ctcoWCAt") -> 1 Your AnsSwer: 1 public int countChr(String str) { 2. if (str.length() return 0; } (0 4. { int count = 0; www. 5. 9. if (str.substring(0, 1).equals("A")) { count = 1 7. { 9. return count + > 1:10 AM 50°F Clear 12/4/2021 呼arrow_forward4. The Fibonacci series: 0, 1, 1, 2,3,5,8,13,21... begins with terms 0 and 1 and has the property that each succeeding term is the sum of the two previous terms. Write a program containing a recursive function that computes and displays the nh Fibonacci number, given the value for n.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning