Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# Unable to execute the program (no compilation error)

Alexie Chong
Greenhorn
Posts: 3
Dear experts,

I am doing my assignment on finding how many numbers in N digit satisfy K requirement.
However, when i am testing the code, i could compile it but i couldn't execute it.
I am wondering if i made mistake in the as when i comment this out, my program is able to execute,though i didn't get the right output value

Logic of my codes (example):

N = 15, K = 3

When N = 1, result = 0 + (N%10)
= 0 + (1%10)
= 1

y = N/10
= 1/10
= 0

x = 1 + 0
= 1
return x = 1

if (sumOfDigits(1) == K)
noOfNoSatisfy ++;
----------------------------------------------------
In the case of above, noOfSatisfy still remains as 0
-----------------------------------------------------
When N = 12, result = 0 + (N%10)
= 0 + (12%10)
= 2

y = N/10
= 12/10
= 1

x = 1 + 2
= 3
return x = 3

if (sumOfDigits(3) == K)
noOfNoSatisfy ++;

----------------------------------------------------
In the case of above, noOfSatisfy increase and plus 1
-----------------------------------------------------

Campbell Ritchie
Sheriff
Posts: 48981
60
Welcome to the Ranch

What goes wrong when you try that code? You have to tell us the full details, otherwise we can't help.

Alexie Chong
Greenhorn
Posts: 3
I used to have issue in getting the desired output which i want. Then i realized i made a mistake with the algorithim and have worked it out just fine.
Thanks so much for helping anyway

Campbell Ritchie
Sheriff
Posts: 48981
60
So what was the error?