Reverse the Digits of a Number with do...while loop - C Statement

C examples for Statement:do while

Description

Reverse the Digits of a Number with do...while loop

Demo Code

#include <stdio.h>

int main (void)
{
    int number, right_digit;

    printf ("Enter your number.\n");
    scanf ("%i", &number);

    do//from w  w w .  ja  v  a 2 s  .c o  m
    {
        right_digit = number % 10;
        printf ("%i", right_digit);
        number = number / 10;
    }
    while (number != 0);

    printf ("\n");
    return 0;
}

Result


Related Tutorials