Answered step by step
Verified Expert Solution
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++
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started