A Program to Find the Area of a Square

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


Program to find the area of a square:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int main() {
  5. float l, area;
  6. printf("Enter the value of the length of a side: ");
  7. scanf("%f",&l);
  8. area = pow(l,2);
  9. printf("Area of square: %.2f", area);
  10. return 0;
  11. }

Output:

Enter the value of the length of a side: 3
Area of square: 9.00