Tuesday, April 30, 2013

c Program to Find Area of Square & Circumference of a Circle

Program to Find Area of Square & Circumference of a Circle


#include <stdio.h>
#define PI 3.142
main()
{
float len, r, area, circum;  //len is the length. r is the radius. circum is the  circumference
printf("\nEnter length of a square: ");
scanf("%f", &len);
area = len * len;
printf("\nEnter radius of a circle: ");
scanf("%f", &r);
circum = 2 * PI * r;
printf("\nArea of square = %.2f", area);
printf("\nCircumference of circle = %.2f", circum);
getch();
}


Basic :  The area of a square is given by the formula
area = width × height
But since the width and height are by definition the same, the formula is usually written as
area = s2
where s is the length of one side. In strictly correct mathematical wording the formula above should be spoken as "s raised to the power of 2", meaning s is multiplied by itself. But we usually say it as "s squared". This wording actually comes from the square. The length of a line s multiplied by itself, creates the square of side s. Hence "s squared".


You sometimes see the word 'circumference' to mean the curved line that goes around the circle. Other times it means the length of that line.
The word 'perimeter' is also sometimes used, although this usually refers to the distance around polygons.














No comments:

Post a Comment