Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Amend the program in Question #1 so that it keeps a count of how many of the num

ID: 3797456 • Letter: A

Question

Amend the program in Question #1 so that it keeps a count of how many of the numbers are positive and how many are negative. The program should print out these two totals immediately before terminating. Write a program that asks the user to enter a radius value, and computes the volume of a sphere with that radius. The program should terminate when a non-positive value entered. (Volume of a sphere = 4/3 * pi * r^3.) Write a program containing a loop that counts from 0 to 100 using a variable i, which is incremented each time around the loop. The program should print out the value of i and its 2^i (2 raised to the power of i) values.

Explanation / Answer

2. Extra information needed

3.

#include <iostream>
using namespace std;

int main(){
double radius, volume;
while(true){
cout << "Enter the radius(non-positive to exit): ";
cin >> radius;
if(radius <= 0) break;
volume = (4.0 * 3.14 * radius * radius * radius) / 3.0;
cout << "Volume: " << volume << " ";
}
}

4.

#include <iostream>
#include <cmath>
using namespace std;

int main(){
for(int i = 0; i <= 100; i++){
cout << "i = " << i << ", 2^i = " << pow(2, i) << " ";
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote