Write a C program to find reverse of the given number.
int main() {
int data, mod, res = 0;
printf("Enter the value for data:");
scanf("%d", &data);
/* find reverse of the given number */
while (data > 0) {
mod = data % 10;
res = (res * 10) + mod;
data = data / 10;
}
printf("Reverse of the given number: %d\n", res);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Enter the value for data:19876
Reverse of the given number: 67891
Enter the value for data:19876
Reverse of the given number: 67891
if i given 100 as data then what will be the output for reverse number
ReplyDelete