Friday, June 17, 2016

C Language Code: តំរៀបតួលេខពីឆ្វេងមកស្ដាំ

C Language Code

#include<stdio.h>

int main()
{
    int number, reverseNumber, remainder;
    printf("Reverse Digits of a Positive Number in C \n");
    printf("Enter a number: ");
    scanf("%d", &number);
    if (number < 0)
    {
        printf("You entered a Negative number, Enter a Positive Number \n");
        printf("Press enter to continue... \n");
        fflush(stdin);
        getchar();
        return 0;
    }
    reverseNumber = 0;
    for (remainder = number; remainder != 0; remainder = remainder / 10)
        reverseNumber = 10 * reverseNumber + remainder % 10;
    printf("The reverse number is %d \n", reverseNumber);

    printf("Press enter to continue... \n");
    fflush(stdin);
    getchar();
    return 0;
}

Reverse Number in C Output Screenshot