Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) Write a program that calculates the surface area of a sphere. Prompt the user to enter a positive number by printing the string Enter

image text in transcribed
Q1) Write a program that calculates the surface area of a sphere. Prompt the user to enter a positive number by printing the string "Enter a positive radius: ". If the number is not positive, print the string "Error: number entered is not positive. " and ask again. Do this until the user puts a positive number. If the number is positive, calculate the surface area of a sphere using the formula: SA 4Tr2. The calculation of a sphere must be done in a function called sa sphere (r) that takes a float argument for the radius, and returns a float for the surface area. You may use the prototype: float sa sphere (float radius) Pi should be defined using: #define PI 3.1415 and placed after your #include statement(s). PI can now be used as a constant who's value cannot be changed (cannot assign PI a value). Example program output: Enter a positive radius: -1 Error: number entered is not positive. Enter a positive radius: 7 The surface area is: 615.73 The final output should be the string printed above, "The surface area is: Note: There are NO double spaces. Use %, 2f to display the surface area. You must name your file surf sphere.c. %21n

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

QUESTION 14 Companies with lower costs hun addod fortu

Answered: 1 week ago

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago