C Exercises: Compute the area of a circle given its radius using inline function
1. Circle Area Inline Variants
Write a C program to compute the area of a circle given its radius using inline functions.
Sample Solution:
C Code:
Sample Output:
The area of the circle (radius = 5.000000) is 78.539816 The area of the circle (radius = 12.000000) is 452.389342
Explanation:
The said program is an inline function that computes the area of a circle given its radius. The formula for circle area is πr², where r is the radius. In the inline function, pi is taken as a constant, and the radius is passed as an argument to the function. The function then computes the area using the formula and returns the result. Since it is an inline function, it is inserted directly into the code where it is called. This can improve performance compared to regular function calls.
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to compute the circumference of a circle using an inline function.
- Write a C program to compute the area of an ellipse using inline functions with two radii.
- Write a C program to calculate the area of a circle with a scaling factor applied using an inline function.
- Write a C program to compute the area of a circle and compare it with a user-input value using an inline function.
C Programming Code Editor:
Previous: C Inline function Exercises Home.
Next: Compute absolute difference between two integers using inline function.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.