void function

Write a void function that accepts three parameters, first two pass­by­value, whereas, third is pass­by

reference. The function should add first and second parameters and assign result to the third

parameter. Also, write a C++ statement that uses/calls the function to find the result of adding (37, 23)

and assign it to the variable result.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

template <typename T>
void addition (const T a, const T b, T& c)
{
    c = a + b;
    std::cout << c  << '\n';
}

int main()
{
  int c{};

  addition (27, 32, c );
}
Topic archived. No new replies allowed.