Find smallest digit in a number (Recursion) Dry Run in C

Find smallest digit in a number (Recursion) is an interactive C dry run visualizer from the Recursion programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Find smallest digit in a number (Recursion) Program Code

#include <stdio.h>

int smallestDigit(int n) {
    if(n < 10) {
        return n;
    }
    int lastDigit = n % 10;
    int minInRest = smallestDigit(n / 10);
    return (lastDigit < minInRest) ? lastDigit : minInRest;
}

int main() {
    int num = 739582;
    int result = smallestDigit(num);
    printf("Number: %d\n", num);
    printf("Smallest digit = %d\n", result);
    return 0;
}

View the complete Recursion programs page.

Program Console Find smallest digit in a number (Recursion) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.