Question

Text: Study the given main function, then fill in the missing functions to make the program work. Do not change the main function. Use value and reference parameters as needed. Examine the function calls to determine the parameter lists and return types needed. This program must be written in C++. #include <iostream> using namespace std; void calculateDiameter(float& diameter, float radius) { diameter = 2 * radius; } void calculateCircumference(float& circumference, float diameter) { circumference = 3.14159 * diameter; } float calculateArea(float radius) { return 3.14159 * radius * radius; } int main() { float radius, diameter, circumference, area; cout << "Enter the radius of a circle: "; cin >> radius; calculateDiameter(diameter, radius); calculateCircumference(circumference, diameter); area = calculateArea(radius); cout << "For a circle with radius = " << radius << endl; cout << "Diameter = " << diameter << endl; cout << "Circumference = " << circumference << endl; cout << "Area = " << area << endl; return 0; }

          Text: Study the given main function, then fill in the missing functions to make the program work. Do not change the main function. Use value and reference parameters as needed. Examine the function calls to determine the parameter lists and return types needed.

    This program must be written in C++.

    #include <iostream>
    using namespace std;

    void calculateDiameter(float& diameter, float radius) {
        diameter = 2 * radius;
    }

    void calculateCircumference(float& circumference, float diameter) {
        circumference = 3.14159 * diameter;
    }

    float calculateArea(float radius) {
        return 3.14159 * radius * radius;
    }

    int main() {
        float radius, diameter, circumference, area;
        cout << "Enter the radius of a circle: ";
        cin >> radius;
        calculateDiameter(diameter, radius);
        calculateCircumference(circumference, diameter);
        area = calculateArea(radius);
        cout << "For a circle with radius = " << radius << endl;
        cout << "Diameter = " << diameter << endl;
        cout << "Circumference = " << circumference << endl;
        cout << "Area = " << area << endl;
        return 0;
    }
        
Show more…

Added by Michelle N.

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Text: Study the given main function, then fill in the missing functions to make the program work. Do not change the main function. Use value and reference parameters as needed. Examine the function calls to determine the parameter lists and return types needed. This program must be written in C++. #include <iostream> using namespace std; void calculateDiameter(float& diameter, float radius) { diameter = 2 * radius; } void calculateCircumference(float& circumference, float diameter) { circumference = 3.14159 * diameter; } float calculateArea(float radius) { return 3.14159 * radius * radius; } int main() { float radius, diameter, circumference, area; cout << "Enter the radius of a circle: "; cin >> radius; calculateDiameter(diameter, radius); calculateCircumference(circumference, diameter); area = calculateArea(radius); cout << "For a circle with radius = " << radius << endl; cout << "Diameter = " << diameter << endl; cout << "Circumference = " << circumference << endl; cout << "Area = " << area << endl; return 0; }
Close icon
Play audio
Feedback
Powered by NumerAI
Danielle Fairburn Ivan Kochetkov
Jennifer Stoner verified

Akash M and 71 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
c-write-programs-for-the-following-vs17-express-consider-the-following-program-in-which-the-statements-are-in-the-incorrect-order-rearrange-the-statements-so-that-the-program-prompts-the-use-32076

(C++) Write programs for the following (VS17 Express) Consider the following program in which the statements are in the incorrect order: Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Format the output to two decimal places. #include <iostream> #include <iomanip> #include <cmath> const double PI = 3.14159; int main() { double height, radius; cout << "Enter the height of the cylinder: "; cin >> height; cout << endl; cout << "Enter the radius of the base of the cylinder: "; cin >> radius; cout << endl; cout << fixed << showpoint << setprecision(2); cout << "Volume of the cylinder = " << PI * pow(radius, 2.0) * height << endl; cout << "Surface area: " << 2 * PI * radius * height + 2 * PI * pow(radius, 2.0) << endl; return 0; }

Akash M.

write-a-c-program-to-input-radius-of-circle-from-user-and-find-diameter-circumference-and-area-of-the-given-circle-using-separate-functions-input-and-output-should-be-in-main-91086

Write a C++ program to input radius of circle from user and find diameter, circumference and area of the given circle using separate functions. (Input and output should be in main()).

Shelayah R.

includeiostream-using-namespace-std-trace-the-program-int-funcint-a-int-b-if-a-b-a-b-b-2-return-b-else-a-b-b-2-return-b-int-main-int-x-2-y-4-z-0-cout-x-x-y-y-z-z-endl-int-z-funcx-y-cout-x-x-62677

#include<iostream> using namespace std; /*trace the program*/ int func(int& a, int b) { if (a > b) { a = b++; b += 2; return b; } else { a = --b; b -= 2; return b; } } int main() { int x = 2, y = 4, z = 0; cout << "X = " << x << " Y = " << y << " Z = " << z << endl; z = func(x, y); cout << "X = " << x << " Y = " << y << " Z = " << z << endl; x = func(y, z); cout << "X = " << x << " Y = " << y << " Z = " << z << endl; system("pause"); return 0; }

Deepak K.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,925 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,697 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,339 solutions

*

Transcript

-
00:01 For the given question, here is the rearranged program that prompts the user for input and then calculates the space, volume and surface area of a cylinder...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever