C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey 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:

  C How to Program (8th Edition), 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
Write a function in C language that takes the time as three integer arguments (for hours, minutes, and seconds) and returns the number of seconds since the last time the clock “struck 12.” Use this function to calculate the amount of time in seconds between two times, both of which are within one 12-hour cycle of the clock.
Write a function in C language which takes an integer as parameter and returns the number of non zero digits in the number passed as argument.
Write a function in C language which takes an integer as parameter and returns the sum of all non zero digits in the number passed as argument to the function.

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Python - bracket parenthesis and braces; Author: MicroNG;https://www.youtube.com/watch?v=X5b7CtABvrk;License: Standard Youtube License