C Examples

Wap in C to Find out the Area by PIE

The Program in C to Find out the Area by PIE is given below:

#include <stdio.h>
#include <math.h> // for M_PI constant

int main() {
    double radius, area;
    printf("Enter the radius of the circle: ");
    scanf("%lf", &radius);
    area = M_PI * pow(radius, 2); // pi * r^2
    printf("The area of the circle with radius %lf is %lf", radius, area);
    return 0;
}

Output:

Enter the radius of the circle: 7
The area of the circle with radius 7.000000 is 153.860000

Pro-Tips💡

This program uses the scanf function to read a double value input by the user and store it in the variable radius.

The pow function from math.h library is used to calculate the square of the radius, and then the area of the circle is calculated using the formula pi * r^2.

The printf function is then used to print the area of the circle.

Note that the PI is defined as a constant using #define preprocessor statement, which assigns a value of 3.14 to the constant PI, which can be used in the area calculation.

Please keep in mind that this is an approximation of PI and the value of PI is defined up to 15 decimal places.

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X