1// Take two integers, return the quotient and remainder
2fn divmod(dividend: isize, divisor: isize) -> (isize, isize) {
3 (dividend / divisor, dividend % divisor)
4}
5
6fn main() {
7 let (q, r) = divmod(14, 3);
8 println!("divmod = quotient {}, remainder {} ", q, r);
9}
1// Take two integers, return the quotient and remainder
2
3#include <iostream>
4using namespace std;
5
6auto divmod(int dividend, int divisor) {
7 struct result {int quotient; int remainder;};
8 return result {dividend / divisor, dividend % divisor};
9}
10
11int main() {
12 auto result = divmod(14, 3);
13 cout << result.quotient << ", " << result.remainder << endl;
14
15 // or
16
17 auto [quotient, remainder] = divmod(14, 3);
18 cout << quotient << ", " << remainder << endl;
19}