I have been looking at this and cannot figure out why my function will not return this int. It does make it into the if(... prints "test 32" but will not return the given value(123456789).
function is a group of statements that is given a name, and which can be called from some point of the program. The most common syntax to define a function is:
type name ( parameter1, parameter2, ...) { statements }
#include <iostream>
using namespace std;
int addition (int a, int b)
{
int r;
r=a+b;
return r;
}
int main ()
{
int z;
z = addition (5,3);
cout << "The result is " << z;
}
I also doubt that that sizeof() call in your function is really doing what you think. It is not giving you the number of elements in your array, it is giving you the size of the pointer.