Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

C program that uses a function to calculate the area of a rectangle.

#include <stdio.h>

// Function to calculate the area of a rectangle
float calculateRectangleArea(float length, float width) {
return length * width;
}

int main() {
float length, width;

// Taking input for the length and width of the rectangle
printf(“Enter the length of the rectangle: “);
scanf(“%f”, &length);

printf(“Enter the width of the rectangle: “);
scanf(“%f”, &width);

// Calling the function to calculate the area and printing the result
float area = calculateRectangleArea(length, width);
printf(“The area of the rectangle is: %.2f square unitsn”, area);

return 0;
}