KCE / Java

Java Programming Language
0 stars 3 forks source link

CoreTask#5: DigitSum - Submit Your Code in Comment Section #30

Open ErSKS opened 5 years ago

ErSKS commented 5 years ago

CoreTask#5: DigitSum - Write a function named isDigitSum that returns 1 if sum of all digits of the first argument is less than the second argument and 0 otherwise. For example isDigitSum(32121,10 ) would return 1 because 3+2+1+2+1 = 9 < 10. More examples: isDigitSum(32121,9) returns 0, isDigitSum(13, 6) returns 1, isDigitSum(3, 3) returns 0 The function should return -1 if either argument is negative, so isDigitSum(-543, 3) returns -1. The function signature is int isDigitSum(int n, int m)