Chapter 2 – Q #12: Land Calculation – Tony Gaddis – Starting Out With C++

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


  1. I declared a double data type constant and initialize given value.
  2. I declared another double variable named number of acer and initialize given value.
  3. I declared a double data type variable named total acer.
  4. Then, calculate acer and store in total acer variable.
  5. In last, display output of distance on the screen.
  6. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File


Post a Comment

0 Comments