C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
The program helps you calculate the area and perimeter of a rectangle.
It also calculates the area and the circumference of the circle.
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
*/
#include <stdio.h>
main()
{
float length, breadth, radius, aor, por, aoc, coc;
printf ("\nEnter the Length and Breadth of the Rectangle: ");
scanf("%f %f", &length, &breadth);
printf("\nEnter the Radius of the Circle: ");
scanf("%f", &radius);
aor = length*breadth;
por= 2*(length+breadth);
aoc = 3.14*radius*radius;
coc = 2*radius*3.14;
printf("\nThe area of the rectangle is: %f", aor);
printf("\nThe perimeter of the rectangle is: %f ", por);
printf("\n\nThe area of the Circle with radius %f is: %f ", radius, aoc);
printf("\nThe circumference of the same circle is: %f", coc);
}
It also calculates the area and the circumference of the circle.
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
*/
#include <stdio.h>
main()
{
float length, breadth, radius, aor, por, aoc, coc;
printf ("\nEnter the Length and Breadth of the Rectangle: ");
scanf("%f %f", &length, &breadth);
printf("\nEnter the Radius of the Circle: ");
scanf("%f", &radius);
aor = length*breadth;
por= 2*(length+breadth);
aoc = 3.14*radius*radius;
coc = 2*radius*3.14;
printf("\nThe area of the rectangle is: %f", aor);
printf("\nThe perimeter of the rectangle is: %f ", por);
printf("\n\nThe area of the Circle with radius %f is: %f ", radius, aoc);
printf("\nThe circumference of the same circle is: %f", coc);
}
Comments
The formula of circumference is = 2 pi r (pi's symbol)
where r = the radius of the circle
and pi = 3.14(Approx)
Newly Launched C Programming Language Learning Hotspot.
Pickupc.com