C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.


How to write a C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle in C Programming Language ?

Solution:
  1. The program helps you calculate the area and perimeter of a rectangle.
  2. It also calculates the area and the circumference of the circle.
  3. The values of Length, Breadth and Radius are to be entered through the keyboard.
The length and breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area and perimeter of the rectangle, and the area and the circumference of the circle.

/*
aor: area of rectangle
por: perimeter of rectangle
aoc: area of circle
coc: circumference of circle
*/

The circumference of a circle is same as the perimeter that is the distance around the outer edge. 

The formula of circumference is = 2 pi r (pi's symbol) 
where r = the radius of the circle 
and pi = 3.14(Approx)


  1. #include <stdio.h>

  2. //C program to find Area and Circumference of a Circle with Sample Input and Output.

  3. main()
  4. {
  5. float length, breadth, radius, aor, por, aoc, coc;
  6.  
  7. printf ("\nEnter the Length and Breadth of the Rectangle: ");
  8. scanf("%f %f", &length, &amp;breadth);
  9.  
  10. printf("\nEnter the Radius of the Circle: ");
  11. scanf("%f", &radius);
  12.  
  13. aor = length*breadth;
  14. por= 2*(length+breadth);
  15.  
  16.  
  17. aoc = 3.14*radius*radius;
  18.  
  19. coc = 2*radius*3.14;
  20.  
  21. printf("\nThe area of the rectangle is: %f", aor);
  22.  
  23. printf("\nThe perimeter of the rectangle is: %f ", por);
  24.  
  25.  
  26. printf("\n\nThe area of the Circle with radius %f is: %f ", radius, aoc);
  27.  
  28. printf("\nThe circumference of the same circle is: %f", coc);
  29.  
  30. }


Learn More :