I'm trying to solve the following problem using DESVIO CONDICIONAL COMPOSTO
. But I do not know how to calculate the numbers that make up the digit.
Require an integer value between 100 and 999. If the value read is less than 500, display the sum between its component numbers. If not, subtract your components.
I just know that I should use IF
and ELSE
, where I will put this condition
if(nb > 500 ) {
for the sum of the component numbers to occur.
What I broke my mind but I really could not come to a conclusion is how I will do the sum!
For example, if the number is 328, how will I add the numbers 3, 2 and 8?