C program to print the given number in reverse order

Printing the number in Reverse Order

In this post, i had shared a c program that will help you guys to print the inputted number into reverse order.

For E.g. If the number is 123456789
              Output will be:    987654321

Let us check out the code:


#include <stdio.h> 
#include <conio.h>
void main()
{
  long int n,a=0;
  clrscr();
  printf("enter no.: ");
  scanf("%ld",&n);
  while(n!=0)
  {
 a=a*10;
 a=a+(n%10);
 n=n/10;
  }
  printf("\nReverse number is: %ld",a);
  getch();
}









Happy Coding :)

Comments

Popular posts from this blog

MultiSelection of Item in Recycler View

Upload Image From Android To Php Server

Merge Sort