Evaluate number properties using while-based nested loops (while) Dry Run in C

Evaluate number properties using while-based nested loops (while) 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.

Evaluate number properties using while-based nested loops (while) Program Code

#include <stdio.h>
int main() {
    int limit;
    printf("Enter limit: ");
    scanf("%d", &limit);
    
    printf("\nNumber\tDivisors\tSum\tClassification\n");
    printf("------\t---------\t---\t-------------\n");
    
    int num = 1;
    while(num <= limit) {
        // Count divisors and calculate sum using while loop
        int count = 0;
        int sum = 0;
        int i = 1;
        
        while(i <= num) {
            if(num % i == 0) {
                count++;
                sum += i;
            }
            i++;
        }
        
        // Determine classification
        int properSum = sum - num;
        char* classification;
        if(properSum == num) classification = "PERFECT";
        else if(properSum > num) classification = "ABUNDANT";
        else classification = "DEFICIENT";
        
        printf("%d\t%d\t\t%d\t%s\n", num, count, sum, classification);
        num++;
    }
    return 0;
}

View the complete Nested programs page.

Program Console Evaluate number properties using while-based nested loops (while) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.