1.
Fix the errors in the code below so that it prints the area of a circle with radius 5. Use cmath functions to get an accurate value for pi.
12 / 8 = 1.5.
#include <iostream>
using namespace std;
void divide(double a, double b) {
cout << a / b;
}
int main() {
int a = 8;
int b = 12;
cout << b << " / " << a << " = ";
divide (b, a);
}
a
minus the natural log of a
and prints the difference. You will need to use cmath functions.
intDivision
that takes two doubles as parameters and prints the quotient of the integer division of the first number divided by the second. Be sure to include any necessary headers.
#include <iostream>
#include <cmath>
using namespace std;
void gpaBoost(double GPA) {
int betterGPA = ceil(GPA);
cout << betterGPA << ".000";
}
volumePrism
that takes three double
sidelengths as parameters, and calculates and prints the volume of a the rectangular prism. Be sure to include any necessary headers.
tanD
that prints the tangent of an angle given as a double
in degrees. Use 3.14 for pi. Be sure to include any necessary headers.
#include <iostream>
#include <cmath>
using namespace std;
void tanDegrees(double degrees) {
double radians = degrees * (2 * 3.14) / 360.0;
double tangent = tan(radians);
cout << tangent;
}
volumeSphere
that takes a double
radius as a parameter, and calculates and prints the volume of a sphere with that radius. Use 3.14 for pi
. Be sure to include any necessary headers.