Challenge: Calculate (a + b)^3

This challenge will test your knowledge of operator precedence.

Problem Statement

The task is to compute (a+b)3(a + b)^3 and display it on the console. The following mathematical formula is expanded as:

(a+b)3=a3+b3+3ab(a+b)(a + b)^3 = a^3 + b^3 + 3ab(a+b)

​​

Sample Input

a = 2
b = 2

Output

64

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Note: There is a test function given in the code for testing purposes. Do not modify it.

Important Note: The power of xyx^y is calculated as datatype :: pow(x,y). Here, the data type is the return value of the power function.

Good luck!🤞

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy