Question: Due date: 1 1 : 5 9 pm , Oct 1 1 , 2 0 2 4 This is an individual assignment. Part of the

Due date: 11:59pm, Oct 11,2024
This is an individual assignment. Part of the assignment will be graded automatically. Make sure that your code compiles without warnings/errors and produces the required output. Also use the file names and structures indicated as requested. Deviation from that might result in 0 mark.
Your code MUST compile and run in the CSIL machines using the steps covered in class (see the Before You Submit section for details). It is possible that even with warnings your code would compile. But this still indicates there is something wrong with you code and you have to fix them, or marks will be deducted.
Your code MUST be readable and have reasonable documentation (comments) explaining what it does. Use your own judgement, for example, no need to explain \( i+=2\) is increasing \( i \) by 2, but explain how variables are used to achieve something, what a certain loop is doing, and the purpose of each \#include.
Description
There is a total of 3 questions in this assignment. For each question, write your answer in a single file along with the required information stated in the question. Unless otherwise specified, do not include any preexisting libraries in your answers. You can however write your own helper functions. Also, do not print anything unless the question asks you to. None of these files should contain the main function. (except for Question 3).
Question \(1[6\) marks]
Write a recursive solution that does exactly the same as what the function in Question 1 of Assignment 1 does. That is, replaces a specific digit in an int number with another digit and returns the result as an int. Return the same number if the target/replacement character is not a digit. Use this function header:
int replaceDigitsRecursive(int number, char target, char replacement)
For example (for more examples refer to the description in Assignment 1):
replaceDigitsRecursive(1,'1','2') should return 2
replaceDigitsRecursive (-232,'3','0') should return -202
replaceDigitsRecursive(\(998,{}^{\prime}9\)','0') should return 8(leading zeros will not be part of the resulting number)
You can assume the number does not have leading zeros (e.g., we will not call replaceDigitsRecursive(01,'1','2'), except when the number is actually zero (i.e., we might call replaceDigitsRecursive(0,11',1'\()\)).
This question aims to let you practice recursion. One way to do so is to look at your answer for Assignment 1, separate the recursive case (most likely where you use a loop) from the base case (most likely the last step you do before returning the result). You should be able to see a significant simplification to your code. Do not use any global or static variables, or pass-by-reference (if you do so you get 0 for this question).
Depends on how you solve this, you might have to create a recursive helper function that passes an extra parameter preserving the partial answer. IOnly include the a2_question1.h header file and the function definition (and your helper functions, if any) in the source file and name it as a2_question1.c.
Due date: 1 1 : 5 9 pm , Oct 1 1 , 2 0 2 4 This

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!