C Program to reverse a number
C programming Tutorials

C Program to Reverse a Number

C Program to Reverse a Number

C Program to Reverse a Number or find the reverse of a number is mostly asked in University exam.

The program is given below

#include <stdio.h>

#include<conio.h>

void main( )
{

int n, reverse = 0, remainder;

printf(“Enter an integer: “);

scanf(“%d”, &n);

while (n != 0) {

remainder = n % 10;

reverse = reverse * 10 + remainder;

n /= 10;

}

printf(“Reversed number = %d”, reverse);

getch();

}

Output

C Program to Reverse a Number

Leave a Reply

Your email address will not be published. Required fields are marked *