Question: Write a function ( in C programming language ) that replaces a specific digit in an int number with another digit and returns the result

Write a function (in C programming language) that 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 replaceDigits(int number, char target, char replacement)
For example:
replaceDigits(1,1,2) should return 2
replaceDigits(-232,3,0) should return -202
replaceDigits(123,4,5) should return 123
replaceDigits(1223,!,?) should return 1223
*NOTE: Do NOT add main function, print function, and any pre-existing C libraries (instead include only a header file called "question1.h", and the function definition and any helper functions) to the code. I do not want it to print anything, but only return the results.
Thanks in advance.

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!