4. You are given the following functions: int functionA (int a) { printf ("a-td\n", a); if (a--1) return 1; else return functionB (a-1) 2; int functionB (int b) { printf ("b-td\n",b); if (b=-1) return 1; else return functionA (b-1) *3; Write the main function. Your main function should prompt the user for input and then call the mutual recursion by passing in the user's input. The guidelines are described below. int main () { //declare int a to receive user input and int result to receive result of mutual recursion //using a while loop, prompt user for input. The number entered //must be bigger than 1, otherwise repeat user input with an error //message. //call functionA () with int a as input argument. Receive the result in int result. //print result return 0;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 9SA
icon
Related questions
Question
4. You are given the following functions:
int functionA(int a) {
printf ("a-sd\n", a);
if (a==1)
return 1;
else
return functionB (a-1) *2;
int functionB (int b) {
printf ("b=3d\n",b);
if (b--1)
return 1;
else
return functionA (b-1) *3;
Write the main function. Your main function should prompt the user for input and then call the
mutual recursion by passing in the user's input. The guidelines are described below.
int main () {
//declare int a to receive user input and int result to receive
result of mutual recursion
//using a while loop, prompt user for input. The number entered
//must be bigger than 1, otherwise repeat user input with an error
//message.
//call functionA () with int a as input argument. Receive the
result in int result.
//print result
return 0;
Transcribed Image Text:4. You are given the following functions: int functionA(int a) { printf ("a-sd\n", a); if (a==1) return 1; else return functionB (a-1) *2; int functionB (int b) { printf ("b=3d\n",b); if (b--1) return 1; else return functionA (b-1) *3; Write the main function. Your main function should prompt the user for input and then call the mutual recursion by passing in the user's input. The guidelines are described below. int main () { //declare int a to receive user input and int result to receive result of mutual recursion //using a while loop, prompt user for input. The number entered //must be bigger than 1, otherwise repeat user input with an error //message. //call functionA () with int a as input argument. Receive the result in int result. //print result return 0;
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr