‘C’ to reverse an integer.

C File =>


/* Write a function in ‘C’ to reverse an integer. Use this in main */

#include<stdio.h>
int main() 
{
int num;

    // function to compute reverse
     void reverse_num(int n)
     {
          int r,sum=0;
          printf("\n Reverse of %d is ",n);
           while(n>0)
          {
               r=n%10;
               printf("%d",r);
               n=n/10;
           }
       }

       printf("\n Enter number : ");
       scanf("%d",&num);

      //calling function 
      reverse_num(num);

      return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.