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
In C++
Please write a C++ programe
C Programming Problem : Write a C program with a function that takes an integer value (1 <- integer value < 9999) and returns the number with its digits reversed. For example, given the number 6798, the function should return 8976. Those two- original number and reversed number- numbers will pass to another function as parameters and calculate their sum. The program should use the function reverseDigits to reverse the digits and SumOriginalReverse to calculate their sum. Your output should appear in the following format: Output reverse digiS 4321 Main Enter a number between 1 and 9999: 6798 The number with its digits reversed is: 8976 6798 + 8976 - 15774 12.34 JomoriginalRevers Enter a number between I and 9999: 6655 The number with its digits reversed is: 5566 6655 + 5566 = 12221 Enter a number between 1 and 9999: 8 The number with its digits reversed is: 8 8 + 8 = 16 Enter a number between 1 and 9999: 123 The number with its digits reversed is: 321 123 + 321 = 444 Enter a number…

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