9. Write an Algorithm to input a number and check that sum of the
digits of that number is odd or even .
Ex: Input - 245 Output - Odd Input -91 Output - even
[5]
Answers
Answered by
0
Explanation:
General Algorithm for sum of digits in a given number:
Get the number
Declare a variable to store the sum and set it to 0
Repeat the next two steps till the number is not 0
Get the rightmost digit of the number with help of remainder ‘%’ operator by dividing it with 10 and add it to sum.
Divide the number by 10 with help of ‘/’ operator
Print or return the sum
Similar questions