MYPROGRAMMINGLAB WITH PEARSON ETEXT
MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 15.5E

Write a C++ program that prompts the user for the radius of a circle, then calls inline function circleArea to calculate the area of that circle.

Expert Solution & Answer
Check Mark
Program Plan Intro

Program Plan:

An inline function circleArea() is defines to calculate the area of circle.

Variable radiusValue is used to save the value of radius entered by user.

Program Description: Purpose of the program is to define an inline function circleArea() to calculate the area of circle. The formula used to calculate area of circle is =II×r2.

Explanation of Solution

Program: Following is C++ Program that prompt user to enter radius of circle calculates area of circle by calling inline function circleArea.

//include necessary header files
#include <iostream>
usingnamespace std; 
/*The inline function circleArea is defined which takes input argument 
radius and calculates the area of circle */
inlinedoublecircleArea( constdouble radius ) 
{ 
// formula for Radius = pi * ( radius ^ 2 ) 
return (3.14) * radius * radius; 
} 
//start of main method 
intmain()
{

// Declare variables to store the value of radius 
doubleradiusValue; 

// Prompt user to enter the value of radius 
cout<<"\nEnter the radius of your circle: "; 

// read the value of radius from user 
cin>>radiusValue; 

// calculate the area of circle and finally display the result 
cout<<"Area of circle with radius "<<radiusValue<<
" is "<<circleArea( radiusValue ) <<endl; 
}//end of main 

Explanation:

The given C++ program calculates the area of circle using inline function.

  • Import the essential header and initialize the main() function.
  • Define inline function circleArea with radius as argument.
  • Declare variable radiusValue for radius of the circle.
  • Formula used to calculate the area of circle is =?×r2.
  • Prompt user to enter the radius of circle.
  • Calculate and finally display the output.

Sample Output:

  MYPROGRAMMINGLAB WITH PEARSON ETEXT, Chapter 15, Problem 15.5E

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
03:47
Students have asked these similar questions
(use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.
1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).
Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Python - bracket parenthesis and braces; Author: MicroNG;https://www.youtube.com/watch?v=X5b7CtABvrk;License: Standard Youtube License