C Program to Reverse a Given Number

This c program takes an integer as input, stores the original number in a separate variable, and then reverses the digits of the number using a while loop. The reversed number is then displayed on the screen along with the original number.

Program :

#include<stdio.h>
#include<conio.h>
main()
{
int n,r=0;
printf(“Enter a number to reverse : “);
scanf(“%d”,&n);
while(n!=0)
{
r=r*10;
r=r+n%10;
n=n/10;
}
printf(“Reverse of Entered Number is = %d\n”,r);
}

Output :

Leave a Comment

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

Shopping Basket
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
Verified by MonsterInsights