Check abundant and deficient numbers (for loop) Dry Run in C

Check abundant and deficient numbers (for loop) is an interactive C dry run visualizer from the Nested 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.

Check abundant and deficient numbers (for loop) Program Code

#include <stdio.h>
int main() {
    int limit, num, i;
    printf("Enter limit: ");
    scanf("%d", &limit);
    
    printf("Number\tSum\tClassification\n");
    for(num = 1; num <= limit; num++) {
        // Sum proper divisors inline
        int sum = 0;
        for(i = 1; i <= num/2; i++) {
            if(num % i == 0) sum += i;
        }
        
        printf("%d\t%d\t", num, sum);
        if(sum < num) {
            printf("DEFICIENT\n");
        } else if(sum == num) {
            printf("PERFECT\n");
        } else {
            printf("ABUNDANT\n");
        }
    }
    return 0;
}

View the complete Nested programs page.

Program Console Check abundant and deficient numbers (for loop) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.