xxxxxxxxxx
#include<stdio.h>
int main(){
int n=23450;
int rev_num = 0;
while(n!=0){
rev_num = rev_num * 10 + n%10;
n = n/10;
}
printf("%d", rev_num);
}
xxxxxxxxxx
#include <stdio.h>
int main() {
int n, reverse = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}
printf("Reversed number = %d", reverse);
return 0;
}
xxxxxxxxxx
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char numberString[20];
int number;
printf("Please enter a positive integer: ");
scanf("%s", numberString);
number = atoi(numberString);
printf("Original number: %d\n", number);
int length = strlen(numberString);
printf("Reversed number: ");
for (int i = length - 1; i >= 0; i--) {
printf("%c", numberString[i]);
}
printf("\n");
return 0;
}
xxxxxxxxxx
#include<stdio.h>
int main()
{
int r,temp,num,sum=0;
printf("the given number: ");
scanf("%d" ,&num);
temp=num;
while(temp!=0)
{
r=temp%10;
sum=sum*10+r;
temp=temp/10;
}
printf("reverse number:%d\n",sum);
}