0

Write a c program to reverse a given number. Can anyone help out please

5th Mar 2021, 11:08 AM
Adi
Adi - avatar
4 odpowiedzi
+ 2
#include<stdio.h> int main() { int n,reverse=0,rem; printf("enter number"); scanf("%d",&n); while( n!=0) { rem=n%10; reverse=reverse*10+rem; n/=10; } printf("reverse number is %d",reverse); return 0; }
5th Mar 2021, 11:27 AM
Ranita Dey
Ranita Dey - avatar
+ 4
Show your attempts Adi!
5th Mar 2021, 11:21 AM
Abhiyantā
Abhiyantā - avatar
+ 3
I googled "reverse a number in c" and first result was: https://www.programiz.com/c-programming/examples/reverse-number
5th Mar 2021, 11:22 AM
arturop200
arturop200 - avatar
0
Thank you 😊 Ranita Dey and Arturop
5th Mar 2021, 12:44 PM
Adi
Adi - avatar