external_2.c
Source Code
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include<stdio.h>
int reverse(int);
int main() {
int num;
printf("\nEnter a non-negative integer: ");
scanf("%d", &num);
if(num < 0) num = -num;
printf("\nReverse number: %d", reverse(num));
return 0;
}
int reverse(int num) {
int rev = 0;
while(num > 0) {
rev = (rev * 10) + num % 10;
num/= 10;
}
return rev;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21