Online Compiler C

#include <stdio.h> int main (void) { int max=0 ,min=0 ,num; scanf ("%d", &num); while(num > 0){ int digit = num%10; if(digit > max ){ max = digit; } if(digit < min ){ min = digit; } num /= 10; } int sum ; sum = min + max; printf("%d\n", sum); return 0; }
1) This code reads an integer input, then finds the smallest and largest digits in that number. Finally, it calculates and prints the sum of these two digits.

2) Hints:  
   - Notice how the code initializes `min` and `max` to 0. Think about what happens if all digits are larger than 0.  
   - The loop continues while `num > 0`. What happens if the input number is negative?