Given a number, write a c program using while loop to reverse the digits of the number.
Answer»
#includeint main(){int rev=0,rem,n;scanf("%d",&n);while(n!=0){rev=rev*10+n%10; n/=10;}printf("reverse:%d",rev);Explanation:n=1234 //inputwhile(n!=0){ // runs the loop until n is !=0rev=rev*10+n%10; //RETURNSLAST digit i.e 4n/=10; // returns all DIGITSEXCEPT last digit i.e 123}