Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Requirement For each exercise, the output format of your program should EXACTLY follow that of the sample run. Exercise 1 (20%) Please write a C++

image text in transcribed

Requirement For each exercise, the output format of your program should EXACTLY follow that of the sample run. Exercise 1 (20%) Please write a C++ program to read the radius (n) of a sphere, and then calculate its volume, rounded to four decimal places by using the following formula: Volume = r3 You can assume that n = 3.1416 and the user inputs are integers larger than zero. The following shows how to display (not to change) a floating point number in different decimal places by using %f and printf(): double d = 1.23456789; 17 Output:d = 1.234568 (rounded to six decimal places (default)) printf("d = %f ", d); 11 Output:d = 1.2 (rounded to one decimal place) printf("d = %. 1f ", d); // Output:d = 1.2346 (rounded to four decimal places) printf("d = %.4f ", d); A sample run is shown as follows (underlined bold characters in blue are user input): Sample Run Input radius: 3 Volume = 113.0976 Please name your C++ source file as Lab1Ex1.cpp

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_2

Step: 3

blur-text-image_3

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

LO3 Name the seven categories of HR functions.

Answered: 1 week ago