For the area of a rectangle, we have to take input of the length and width of the rectangle.
to find the area of the rectangle follow the steps;
Step 1: declare two variable names as length and width of int or float data type.
Step 2: Take input of the length and width of the rectangle from the user by using the scanf () function.
Step 3: calculate the area of the rectangle by using the formula.
Step 4: area= length * width.
Step 5: now print the result of the rectangle by using the printf() function.
#include <stdio.h> int main() { float length, width ; printf("Enter length of the rectangle: "); scanf("%f", &length); printf("Enter width of the rectangle: "); scanf("%f", &width); printf("Area of rectangle = %0.2f units ", length*width); return 0; }
output
Enter length of the rectangle: 5
Enter width of the rectangle: 6
Area of rectangle = 30.00 units
...Program finished with exit code 0
Press ENTER to exit console.