Hi!
How are ya!
Anyway, I've just begun learning programning and I was trying the whole recursive program tutorial. I dunno what the problem is but every time the recursive function returns an integer to main it changes into 30866468. Here is what I got:
Thanks for any help.Code:#include <iostream> using namespace std; int recursion (int x, int y); int main () { int num_user; int num_result = 0; cout<<"Input a number\n"; cin>> num_user; num_result = recursion(num_user, 1); cout<< num_result; _flushall(); cin.get(); } int recursion (int x, int y) { y *= x; if (x == 1) { return y; } recursion ((x - 1), y); }



LinkBack URL
About LinkBacks



CornedBee