Posts

Showing posts from March 6, 2021

Largest & Smallest Digits Difference

Largest & Smallest Digits Difference  PROBLEM STATEMENT : A number N is passed as the input. The program must print the difference between the largest and the smallest digits in the number.  Input Format:  The first line will contain the number N.  Boundary Conditions: 10 <= N <= 99999999  Output Format: The difference between the largest and the smallest digits in the number N.  Example Input/Output 1:  Input: 2501  Output: 5  Explanation: The largest digit is 5. The smallest digit is 0. The difference is 5-0 = 5 is printed as the output.  Example Input/Output 2:  Input:  22  Output: 0  Explanation: Both the largest and the smallest digit is 2. Hence the difference 2-2 = 0 is printed as the output. SOLUTION : C (Programming Language) Copy Code #include<stdio.h> #include<stdlib.h> int main() { int n,min,max,u; scanf("%d",&n); min=n%10; max=n%10; while(n) ...