Saturday, 5 January 2019

Filled Under:

Reverse of a number[c programming examples with output]

C programming examples with output

Reverse of a number
Program

#include<stdio.h>
#include<conio.h>
main()
{
      int n,rev=0;
      printf("Enter a number to rev:\n");
      scanf("%d",&n);
      while(n!=0)
      {
         rev=rev*10;
         rev=rev+n%10;
         n=n/10;
      }
      printf("Reverse of entered number is=%d\n",rev);
      getch();
}

Output:
Enter a number to reverse:
1234
Reverse of entered number is=4321

0 komentar:

Post a Comment