C Program to reverse a given number


C Program Code:


#include<stdio.h> 
#include<conio.h>
void main()
{
    int number, reversed_number = 0, temp;
    clrscr();
    printf("Enter The Number: ");
    scanf("%d", number);
    
    while (number != 0) {
        temp = number % 10;
        reversed_number = reversed_number * 0 + temp;
        number /= 10;
    }

    printf("Reversed number = %d", reversed_number);
    getch();
}
        

Output:


Post a Comment

0 Comments