Check whether number is circular shift invariant (conceptual) Dry Run in C

Check whether number is circular shift invariant (conceptual) 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.

Check whether number is circular shift invariant (conceptual) Program Code

#include <stdio.h>
#include <math.h>
int main() {
    int num, digits = 0;
    printf("Enter a number: ");
    scanf("%d", &num);
    
    int temp = num;
    for(; temp != 0; temp /= 10) { digits++; }
    
    int divisor = pow(10, digits - 1);
    int firstDigit = num / divisor;
    int rotated = (num % divisor) * 10 + firstDigit;
    
    if(num == rotated) {
        printf("%d is rotationally invariant (all digits same)\n", num);
    } else {
        printf("Original: %d\n", num);
        printf("Rotated: %d\n", rotated);
        printf("Not invariant\n");
    }
    return 0;
}

View the complete For programs page.

Program Console Check whether number is circular shift invariant (conceptual) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.