-->

Facebook

Jasper Roberts - Blog

Thursday, March 12, 2015

Write a C Program to reverse the given number.

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

void main()
{
  int number,rem;
  int reverse=0;
  printf("Enter an integer number: ");
  scanf("%d", &number);
  while(number!=0)
  {
     rem=number%10;
     reverse=reverse*10+rem;
     number=number/10;
  }
  printf("Reversed Number = %d",reverse);
  getch();
}

OUTPUT:
Enter an integer number: 123
Reversed Number = 321

No comments:

Post a Comment