×
Reviews 4.9/5 Order Now

C++ Program to Create Area Calculation System Assignment Solution

July 11, 2024
Dr. Asha Campbell
Dr. Asha
🇸🇬 Singapore
Programming
A Ph.D. graduate in Computer Science from McGill University, Dr. Campbell has eight years of experience under her belt. Having successfully completed over 800 Perl Homework assignments, her comprehensive understanding of Perl programming concepts and dedication to academic excellence make her a trusted mentor for students seeking guidance.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Write clean, readable code using meaningful variable names and comments. Leverage Python’s built-in libraries to simplify tasks and avoid reinventing the wheel. Always test your code with different inputs and use debugging tools like print() or pdb to troubleshoot errors efficiently.
News
In March 2025, researchers at MIT's Computer Science and Artificial Intelligence Laboratory introduced Exo 2, a new programming language designed to enable high-performance computing with significantly less code, allowing students and developers to achieve state-of-the-art performance with just a few hundred lines.

Instructions

Objective

Write a program to create area calculation system in C++.

Requirements and Specifications

Assignment 3

Write a C++ homework application (including algorithm) that uses a “void” function, “CalculateArea”, to calculate the area of a circle. The function uses two formal parameters (i.e., “radius” [pass by value] and “area” [pass by reference]). The function calculates the area using the formula (i.e., PI * radius2).

The application requires a sentinel controlled loop where program prompts for continuing and expects an entry of ‘Y’ or ‘y’ using the variable “cont”. Within the loop, the application provides for allowing the user to enter the radius of the circle, calls the “CalculateArea” function and displays the value of the circle’s area.

Upload to the Canvas “Assignment 3 Submission” area.

Note: Keep in mind the 3 requirements for functions

  • Function Declaration
  • Function Definition
  • Function Call

Source Code

#include #define PI 3.1416 using namespace std; // Function declaration void CalculateArea(double radius, double &area); int main() { // Define variable to store user input char cont; double radius; // Create variable to store area double area; // Begin with loop while(true) { cout << "Please enter the radius of the circle: "; cin >> radius; // Calculate CalculateArea(radius, area); cout << "The area of the circle with a radius of " << radius << " is: " << area << endl; // Ask if s/he wants to continue cout << "Do you want to calculate a new area? (y/n): "; cin >> cont; if(cont == 'n' || cont == 'N') { break; } } } /** * @brief Function to calculate the area of a circle given its radius. * The function received two parameters. The area (passed by value) and the area (passed by ref) * */ void CalculateArea(double radius, double &area) { // Calculate area area = PI*radius*radius; }

Related Samples

Explore our free programming assignment samples showcasing real-world applications and solutions. Enhance your understanding with practical examples in operating systems, Haskell, Java, embedded systems, C++ and C programming. Discover insights and inspiration for your next project or academic endeavor.