16-bit Sum Product

#include <iostream>
#include <cstdint>
using namespace std;

// Write your code here
void compute(int16_t a,int16_t b,int32_t &sum,int32_t &product) {

    // Write your code here

    sum = static_cast<int32_t> (a) + static_cast<int32_t> (b);
    product = static_cast<int32_t> (a) *  static_cast<int32_t> (b);

}

int main() {
    int16_t a, b;
    cin >> a >> b;

    int32_t sum = 0, product = 0;

    compute(a, b, sum, product);

    cout << sum << " " << product;

    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

3 4

Expected Output

7 12