Find maximum circular rotation of a number Dry Run in C

Find maximum circular rotation of a number is an interactive C dry run visualizer from the For 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 maximum circular rotation of a number Program Code

#include <stdio.h>
#include <math.h>
int main() {
    int num, digits = 0, temp, i;
    printf("Enter a number: ");
    scanf("%d", &num);
    
    for(temp = num; temp != 0; temp /= 10) {
        digits++;
    }
    
    int divisor = pow(10, digits - 1);
    int rotated = num;
    int maxRotation = num;
    
    for(i = 1; i < digits; i++) {
        int lastDigit = rotated % 10;
        rotated = lastDigit * divisor + (rotated / 10);
        if(rotated > maxRotation) {
            maxRotation = rotated;
        }
    }
    
    printf("Maximum circular rotation = %d\n", maxRotation);
    return 0;
}

View the complete For programs page.

Program Console Find maximum circular rotation of a number Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.