c code to reverse integer

  • creverse
  • how to reverse integer in c using functions

    write a program to read an integer number and print the reverse of that number.

    Code

    #include <stdio.h> int reversDigits(int num) { int rev_num = 0; while (num > 0) { rev_num = rev_num * 10 + num % 10; num = num / 10; } return rev_num; } int main() { int n; printf("enter the number\n"); scanf("%d",&n); printf("Reverse of no. is %d", reversDigits(n)); return 0; }