wap to print reverse number of given number in c
Answers
#include <stdio.h>
void main()
{
long num, reverse = 0, temp, remainder;
printf("Enter the number\n");
scanf("%ld", &num);
temp = num;
while (num > 0)
{
remainder = num % 10;
reverse = reverse * 10 + remainder;
num /= 10;
}
printf("Given number = %ld\n", temp);
printf("Its reverse is = %ld\n", reverse);
I am giving you the quick code and for a deep explanation there is a video regarding the same problem. Refer to the given channel on youtube.
MeghTheLifter
The code is here:
#include <stdio.h>
int main()
{
//declaring the variables
int enterednumber = 0,reversednumber = 0;
printf("Enter the number::");
scanf("%d",&enterednumber);
//process for reversing the number
while(enterednumber > 0){
reversednumber = reversednumber*10 + enterednumber%10;
enterednumber = enterednumber / 10;
}
//printing reversed number
printf("The reversed number is ::%d",reversednumber);
return 0;
}