Answers for "cpp function return more two values"

C++
5

c++ return multiple values

#include <tuple>

std::tuple<int, int> divide(int dividend, int divisor) {
    return  std::make_tuple(dividend / divisor, dividend % divisor);
}

#include <iostream>

int main() {
    using namespace std;

    int quotient, remainder;

    tie(quotient, remainder) = divide(14, 3);

    cout << quotient << ',' << remainder << endl;
}
Posted by: Guest on May-16-2020
0

cpp function that returns two arguments

std::tuple<int, int> multiple_outputs(int a, int b){
    return {a, b};
}
Posted by: Guest on February-12-2021

Code answers related to "cpp function return more two values"

Browse Popular Code Answers by Language