C Program to Reverse a Number

#include<stdio.h>
#include<conio.h>

void main( )
{
    int n, rev=0, r;
    printf("Enter a number: ");
    scanf("%d",&n);
  while(n>0)
  {
    r = n % 10;
    rev = rev * 10 + r;
    n = n / 10;
  }
  printf("Reverse value = %d",rev);
  getch( );

No comments:

Post a Comment