There are multiple very basic errors. You need to learn the basics.
For example - void reverse(int number); This should be an int function, and there should not be a semicolon. And after the function there needs to be brackets.
[code cout << rev_num << endl;][/code] Here you print nothing. you never tell the program what rev_num is. You have to call for the reverse function and then print it out in main.
Warning 1 warning C4101: 'reverse_num' : unreferenced local variable
Warning 2 warning C4390: ';' : empty controlled statement found; is this the intent?
Warning 3 warning C4715: 'reverse' : not all control paths return a value
Error 4 error C4700: uninitialized local variable 'number' used
Please make the changes to the code I provided you. Also
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int reverse(int reverse_num)
{
int num;
while (num > 0)
{
reverse_num += num - ((num / 10) * 10);
num /= 10;
if (num > 0);
reverse_num *= 10;
return reverse_num;
}
}
There is some weird stuff going on in there.
1 2 3 4
int num;
while (num > 0)
{
You literally just declared num. Num is not greater than 0 because you never do anything with num.
int reverse(int reverse_num) This is the function you take in from main. You want to use this one.
since I dont know how this reverse thing works, Im not 100% but. I think in the reverse function, you want to switch all the "num" with reverse:num. and switch all the "reverse_num" with "num".
Look here. The user enters his thing in num. Why do you send away number? number is nothing, number literally does not exist. change it to
1 2 3 4 5 6 7 8 9 10 11 12 13
reverse_sum = reverse(num);[code]
the return num; should be outside of the while-loop.
[code]
if (num > 0)
num *= 10;
}
return num;
}
And, As I also said earlier... so I will just quote myself -
since I dont know how this reverse thing works, Im not 100% but. I think in the reverse function, you want to switch all the "num" with reverse:num. and switch all the "reverse_num" with "num".