A Program to Find the Area of a Rectangle

In this example, we are giving a program to find the area of a rectangle. The rule of finding the area of a rectangle is: A = width * height.


Program to find the area of a rectangle:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main() {
  4. float w, h, area;
  5. printf("Enter the value of width and height: ");
  6. scanf("%f %f", &w, &h);
  7. area = w * h;
  8. printf("Area of rectangle: %.2f", area);
  9. return 0;
  10. }

Output:

Enter the value of width and height: 3, 4
Area of rectangle: 12.00