Online Compiler C

#include <stdio.h> int main() { int a=1, sum = 0, max = 0, min = 9, b; scanf("%d", &b); while (a > 0) { a = b % 10; if (a >= max) { max = a; } if (a <= min) { min = a; } b = b / 10; } sum = min + max; printf("%d\n", sum); return 0; }
1) This code calculates the sum of the smallest and largest digits in a given integer. It processes each digit of the input number one by one.

2) Hints:  
   - The loop condition `a > 0` ensures the loop runs as long as there are digits left to process.  
   - The modulo operation `b % 10` extracts the last digit of the number, while `b / 10` removes that digit from the number.