Chapter 2 – Q #12: Land Calculation – Tony Gaddis – Starting Out With C++
Problem: -
One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with 389,767 square feet.
Solution: -
#include <iostream>
using namespace std;
int main()
{
const double one_acer_of_land = 43560;
double number_of_acer = 389767;
double total_acer = 0.0;
total_acer = number_of_acer / one_acer_of_land;
cout << "Number of Acers are " << total_acer << " Acers " << " in Tract of Lands";
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Explanation of this Solution
- I declared a double data type constant and initialize given value.
- I declared another double variable named number of acer and initialize given value.
- I declared a double data type variable named total acer.
- Then, calculate acer and store in total acer variable.
- In last, display output of distance on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments