In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and otherwise it returns a^2 + b^3. int square_cube (int a, int b); For example: square_cube (1,2) should return 1 + 8 = 9. square_cube (10, 3) should return 1000 + 9 = 1009. square_cube (2, -1) should return 8 + 1 = 9. square_cube (-2, -1) should return 4 - 1 = 3.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 3E
icon
Related questions
Question

In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and otherwise it returns a^2 + b^3.

int square_cube (int a, int b);

For example:

  • square_cube (1,2) should return 1 + 8 = 9.
  • square_cube (10, 3) should return 1000 + 9 = 1009.
  • square_cube (2, -1) should return 8 + 1 = 9.
  • square_cube (-2, -1) should return 4 - 1 = 3.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning