I tried to covert this but couldnt figure out what i missed
(I think % is mod????? as i dont know C)
Code:int sum(int n) { int ret; ret = 0; while (n > 0) { ret = ret + (n % 10); n = n / 10; } return (ret); }VB Code:
Public Function sum(ByVal n As Integer) As Integer Dim ret As Integer = 0 Do While n > 0 ret = ret + (n Mod 10) n = n / 10 Loop Return ret End Function
i tested both these functions some times they give the same return value and sometimes they do not...
If n is 25 they both return 7
if n is 36 C++ returns 9, vb returns 10
//////////////////////
thanx worked great, took me a while to figure out it i got it working properly




)
Reply With Quote