Hello, my name is kerry and i just sign up .Well, my question is how do reverse a number input by user using recersive function.Thanks for the help.
You mean recursive funtion.The concept is quite simple.You take a number (to be reversed) and divide it by 10 and add the remainder to another number.As every loop goes by you multiply 10 to the other number and keep adding the remainders till you get 0.
Check this out
m *= 10;
m += n%10;
n /= 10;
the recursive code (function call itself ) will be as follow
int reverse_num (int n,int m) ;
using namespace std;
cout<<"enter number to reverse :";
cout<<reverse_num(n,0)<<endl; //calling the function
int reverse_num(int n,int m)
return m; //base (exit condition)
return reverse_num(n/10,m); //recursive call
int num, rem=0;
printf("\n Enter the number ");
rem = (rem * 10) + (num % 10);
num = num / 10;
printf("\n Reverse of the number is %d", rem);
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"