Return Values w/Functions

Is it possible to call a return value from another function to a different function?? If so, could someone provide a small example?
The code below calls std::pow(2,2) as the parameter to another function, passing the return from std::pow(2,2) directly into the std::pow(std::pow(2,2),2);


1
2
3
4
5
6
7
#include <cmath>

int main()
{
  std::pow(std::pow(2,2),2);
  return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

int max (int a, int b) { return ((a > b) ? (a) : (b)); }

int main ()
{
	std::cout << max(max(4,5), max(2,6)) << std:endl;
	// Function calls when calling another function. The inside functions
	// get evaluated first and their return values then passed
	// to the outermost function. This will work for any function
	// but be aware that the return value should be the same type as the
	// arguments to avoid errors or unexpected output.

	// std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
	// Uncomment this for a pause when not running from terminals to see the output.

	return 0;
}
Topic archived. No new replies allowed.