18th Jan 2021, 2:37 PM
Ira Sarkar
Ira Sarkar - avatar
7 Answers
+ 2
printf("Enter the five digit number: \n"); scanf("%d", &n); while(n>0){ int rem=n%10; revnum=revnum*10 + rem; n=n/10; } printf("The reversed number is: "); printf("%d",revnum); return 0;
18th Jan 2021, 2:44 PM
Abhay
Abhay - avatar
+ 1
Ira Sarkar you didn't told us that you have to solve it without loop. hopefully you got the answer tho.
18th Jan 2021, 2:54 PM
Abhay
Abhay - avatar
+ 1
Ira Sarkar now that you have solved it with inline code, you might enjoy seeing another approach. Here is a way to use recursion to print the number from right to left without using a loop: https://code.sololearn.com/ccK0p8BIKAaS/?ref=app
18th Jan 2021, 9:43 PM
Brian
Brian - avatar
+ 1
Brian yes, thank you.😊
20th Jan 2021, 2:55 PM
Ira Sarkar
Ira Sarkar - avatar
0
Abhay i have got to solve it without loop😅
18th Jan 2021, 2:47 PM
Ira Sarkar
Ira Sarkar - avatar
0
Abhay but I found my answer, I think, not sure. Let me try😅
18th Jan 2021, 2:47 PM
Ira Sarkar
Ira Sarkar - avatar
0
Abhay yes😅 I got it, thanks a lot though!
18th Jan 2021, 3:00 PM
Ira Sarkar
Ira Sarkar - avatar