English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

the function should return the resulted value to the parameter result (call by reference).

2006-10-01 08:19:47 · 2 answers · asked by myheartsuzan 2 in Computers & Internet Programming & Design

2 answers

Sounds like homework to me. Without knowing what computer language, I'm unable to provide an answer. In general there are many ways to solve this problem. One key point:: result should be passed by reference as a parameter to the function, and the answer should be saved to that parameter, rather than passing it back. This sounds like a void function return.

You also need some bounds checking (does n have at least as many digits as k?) If not that's a possible error.

You can either use modulus to do this, or convert n to a string. In c, strings are arrays of chars, so getting the kth, character in the array from the right would be the k-1.

2006-10-01 08:33:31 · answer #1 · answered by Gizmo L 4 · 0 0

You should write the code yourself.

There is a function is all modern languages to convert an item to a string. In C# it would be newstring=Item.ToString(); probably the same in a few other languages to. Then all you need to do is get the length of the string and return the character at position length-k.

2006-10-01 15:38:34 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers