-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse_number.c
More file actions
63 lines (48 loc) · 1009 Bytes
/
reverse_number.c
File metadata and controls
63 lines (48 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<stdio.h>
//without use of function and recursion
int main(){
int n,rem,sum=0;
scanf("%d", &n);
while(n!=0){
rem=n%10;
n=n/10;
sum=sum*10+rem;
}
printf("%d", sum);
}
//with use of recursion and without declaring array
// int fun(int n);
// int main(){
// int n;
// scanf("%d", &n);
// fun(n);
// }
// int fun(int n){
// if(n/10==0){
// printf("%d", n);
// return 0;
// }
// printf("%d", n%10);
// fun(n/10);
// }
// // with use of recursion and declaring array
// int reverse(int a[],int l);
// int main(){
// int n;
// printf("Enter length of array:");
// scanf("%d", &n);
// int arr[n];
// for(int i=0;i<n;i++){
// scanf("%d", &arr[i]);
// }
// reverse(arr,n-1);
// return 0;
// }
// int reverse(int a[],int l){
// if(l==0){
// printf("%d", a[l]);
// return 0;
// }
// printf("%d", a[l]);
// reverse(a,l-1);
// }