The return operator doesn't return a value;

Why can't I print the value of 's' with return.I don't want to do it with 'cout'.


#include <iostream>
using namespace std;

int s;

int surf(int a, int b)
{
s = a*b;
return s;
}

int main()
{
int x, y;
cin >> x;
cin >> y;
surf(x, y);
return 0;
}
return doesn't print anything; it does only what it says: returns the value. The problem, I think, it that you aren't doing anything with that returned value. You might want something like:
int n = surf(x, y); to store the returned value.
Topic archived. No new replies allowed.