Search This Blog


Thursday, 11 April 2019

Program to Reverse a Number in Language C

  Program to Reverse a Number in Language C


Welcome back to codejunction.in , we hope you enjoy our blogs and don't forget to check out our other blogs which will boost your knowledge skills.

In this program the user needs to input a number then the reverse of that number will be processed in the output. 

CODE

#include <stdio.h> 
int main()
{
   int num, rev=0;

   printf("\n Enter a number to Reverse");
   scanf("%d",&num);    // taking value from user in num

   while (num!= 0)
   {
      rev = rev * 10;     
      rev = rev + num%10;
      i       = num/10;
   }

   printf("Reverse of entered number is = %d", rev)

   return 0;
}


OUTPUT

No comments:

Post a Comment