Armstrong number check Dry Run in C

Armstrong number check is an interactive C dry run visualizer from the While 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.

Armstrong number check Program Code

#include <stdio.h>
int main() {
    int num, original, sum = 0, digit, n = 0;
    
    printf("Enter a number: ");
    scanf("%d", &num);
    original = num;
    
    // Count digits
    int temp = num;
    while(temp > 0) {
        n++;
        temp = temp / 10;
    }
    
    // Calculate sum of digits^n
    temp = num;
    while(temp > 0) {
        digit = temp % 10;
        int power = 1, i = 1;
        while(i <= n) {
            power = power * digit;
            i++;
        }
        sum = sum + power;
        temp = temp / 10;
    }
    
    if(sum == original)
        printf("%d is Armstrong\n", original);
    else
        printf("%d is not Armstrong\n", original);
    return 0;
}

View the complete While programs page.

Program Console Armstrong number check Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.