From the keyboard is introduced a string of natural numbers until the value 0.The problem asks to display all of the triples of consecutive introduced numbers(ex: 2 5 15) that have the following property:
(n2==n1/s && n2==n1%s)&&(n3==n1/s && n3==n1%s),where n1,n2,n3 are forming the triplet and s is the sum of the digits of n1.
In our example we have 1 triplet of numbers:
n1=2 n2=5 n3=15...s=1+5=6...15/6=2 and 15%6=5
I am here just to note few things:
1. In your problem's definition it is said that s is the sum of the digits of n1, but in the given example s is the sum of the digits of n3?
In our example we have 1 triplet of numbers:
n1=2 n2=5 n3=15...s=1+5=6...15/6=2 and 15%6=5
2. Your if should be like this if(y==x/s && y==x%s)&&(z==x/s && z==x%s), you missed y==x%s and z==x/s
3. How is 15%6=5? 15%6=3
So your code is OK when you enter x=15, y=2 and z=3 (without y==x%s and z==x/s) . Please read the problem again :)