<u>Input
:</u>
*Processing*
<u>
Output
:</u>
An array full of numbers which is terminated by 0.
<u>
Algorithm:
</u>
1. **Start
2. **Take an array, max, and min as variables.
3. **Get the numbers from the user.
4. **Initialize the max and min variables as a[0].
5. **Now, check if max>a[i]. If true, reinitialize max=a[i].
6. **Check if min<a[i]. If true, reinitialize min=a[i].
7. **Print max and min.
8. **Stop
Answer:
The function in Python is as follows:
def digitSum( n ):
if n == 0:
return 0
if n>0:
return (n % 10 + digitSum(int(n / 10)))
else:
return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))
Explanation:
This defines the method
def digitSum( n ):
This returns 0 if the number is 0
<em> if n == 0:
</em>
<em> return 0
</em>
If the number is greater than 0, this recursively sum up the digits
<em> if n>0:
</em>
<em> return (n % 10 + digitSum(int(n / 10)))
</em>
If the number is lesser than 0, this recursively sum up the absolute value of the digits (i.e. the positive equivalent). The result is then negated
<em> else:
</em>
<em> return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))</em>
C. is the answer to that question
D. half period because it is the converting of bidirectional current flow to unidirectional currency flow.
user input I think I'm not sure though