Write a program to find the reverse of a given number with help of function?

1 answer

Answer

1121470

2026-04-18 21:10

+ Follow

//Reverse of the Number

#include<stdio.h>

#include<conio.h>

int main ()

{

int num,mod,rev=0;

printf("Enter a number:");

scanf("%d", &num);

while (num>0)

{

mod=num%10;

rev=(rev*10)+mod;

num=num/10;

}

printf("Reverse of the given number: %d", rev);

getchar();

return 0;

}

// alternative solution based on reversing the alphanumeric representation of

// the number:

void rev(int me) {

char alpha[32];

sprintf(alpha, "%d", me);

for (const char* cp = alpha + strlen(alpha) - 1; cp >= alpha; --cp) {

putchar(cp); }

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.