Question: In C++ A Pyramid with a square base, 4 triangular faces, and an apex is a square pyramid. Write a function surfaceArea to calculate and

In C++

In C++ A Pyramid with a square base, 4 triangular faces, and

A Pyramid with a square base, 4 triangular faces, and an apex is a square pyramid. Write a function surfaceArea to calculate and return the surface area of a square pyramid. The function takes two double parameters - the base length(b) and slant height(h) of a square pyramid, and calculates and returns the surface area as a double. Function specifications: The function name: surfaceArea The function parameters in this order) o The base length, double o The slant height, double The function return value: surface area, double The function should not print anything. Edge cases: if one or more arguments are not positive numbers, then it should return -1 Sample run 1 (bold is user input) Enter the base length: 3 Enter the slant height: 4 The surface area: 33 Sample run 2 (bold is user input) Enter the base length: 3 Enter the slant height: -1 Invalid values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!