Hide

Problem G
Arithmetic Functions

Your task is to implement the following functions in C++:

#include "arithmeticfunctions.h"

// Compute x^3
int cube(int x){
        ...
}

// Compute the maximum of x and y
int max(int x, int y){
        ...
}

// Compute x - y
int difference(int x, int y){
        ...
}

First, download the files arithmeticfunctions.h and arithmeticfunctions.cpp and put them in the same directory. You should implement the functions in the arithmeticfunctions.cpp file and submit only that file.

It is guaranteed that the results of $x - y$ and $x^3$ always fit in an int.

Testing

The arithmeticfunctions.h file includes a main function that tests your program on some example cases. For further testing, you can modify that file.

Please log in to submit a solution to this problem

Log in