Write a ‘C’ function that returns the k-th digit from the right in the positive integer n.

c) Write a ‘C’ function that returns the k-th digit from the right in the positive integer n. For
example, digit(829,1) returns 9, digit(829,3) returns 8. If k is greater than the number of
digits in n then the function is to return –1. Include appropriate documentation in your
program.


Leave a Reply