Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Question 1(5pt): pyramid, surface area A Pyramid with a square base, 4 triangular faces, and an apex is a square pyramid. Write a function

C++ image text in transcribed

Question 1(5pt): pyramid, surface area 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions