Write a program that calls a function digit(): int digit (int n, int k) This fun
ID: 3613022 • Letter: W
Question
Write a program that calls a function digit():
int digit (int n, int k)
This function returns the k thdigit of the positive integer n. For example, ifn is the integer 29415, then call digit (n, 0)would return the digit 5, and the call digit (n ,2) wouldreturn the digit 4. Note that the digits are numbered from right toleft beginning with the “zeroth” digit.
Sample output1:
Enter a positive integer :87654
Enter the digit number :4
Digit number 4 of 87654 is8
Press any key tocontinue
Sample output2:
Enter a positive integer :87654
Enter the digit number :2
Digit number 2 of 87654 is6
Press any key tocontinue