‘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
Post a Comment
Please do not enter any spam link in message.