...

/

Solution Review: Calculate the Area of the Sphere

Solution Review: Calculate the Area of the Sphere

Let's go over the solution review in this lesson.

We'll cover the following...

Solution #

Press + to interact
#include <iostream>
using namespace std;
int main() {
// Initialize a variable r
double r = 10.1;
// Prints value of r
cout << "r = " << r << endl;
// Initialize a constant pi
const double pi = 3.14;
// Declares a variable area
double area;
// Find the area using a given formula
area = 4*pi*r*r;
// Prints value of area
cout << "area = " << area;
}

Explanation

...