Learn about C Program to Find the Area of a Rectangle Using Functions in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Find the Area of a Rectangle Using Functions
The below Program takes length and breadth as input from the user. Then calculate the area of the rectangle using a function call.
Program:
#include<stdio.h>
float findArea(float l, float b);
int main()
{
float length, width, result;
printf("Enter the length and width of the rectangle: ");
scanf("%f %f", &length, &width);
result = findArea(length, width); //function calling
printf("Area of rectangle = %.2f\n",result);
return 0;
}
// function to find area of rectangle
float findArea(float l, float b)
{
float area;
area = l * b;
return area; //return statement
}
Output:
Enter the length and width of the rectangle: 5 10
Area of rectangle = 50.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Print Inverse Diamond Pattern
C program to print diamond star pattern at the center of the screen