0
sum of digits
how to sort in ascending order this task any on answer this 1.) Display all the numbers between 0 and 200 satisfying all the below conditions. Conditions: i) Sum of the digits should be 9 ii) Digits should be in ascending order i.e., the digit on the left should be lesser than the digit in the right For Example: 27 -> 2+7=9 and 2 is less than 7 For Example: 135 -> 1+3+5=9 and 1 is less than 3 is less than 5
1 Resposta
0
Heyhey, so you define the conditions! try to wrap this in a if/else or switch statement. You can define if statements with || or && to say „or“ or „and“ .
A if statement can have multiple conditions like:
If(numA >= givenNum || numB <= givenNum) {
Do something
}
Its also possible as example
If(numA < givenNum && ( numB > numA || givenNum == numA)){
Do something
This will check if numA is smaller then givenNum AND if numA greater than OR givenNum is equal numA.
}
Ofc the vars are just a example.
Hopefully i helped you to get a startpoint 😉
Happy coding