Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will read the radii of circles. Use an array of records whe

ID: 3816075 • Letter: W

Question

Write a program that will read the radii of circles. Use an array of records where each record will have the radius of the circle read from the keyboard and the Circumference and area of the circle will be calculated by the program. This information (radius, diameter and area) is stored in a binary file. The information in the binary file is then read back into the records and stored in a text output file. Left justify the information for each field.

Each record will consist of the following fields:

radius float

diameter float

area float

You may assume a maximum of 20 records. You may want to include the cmath library. You need to know the formulas for finding the area and circumference of a circle.

Sample Run:

Enter the following information:

Radius of circle:

5

Enter a Y if you would like to input more data

y

Enter the following information:

Radius of circle:

4

Enter a Y if you would like to input more data

y

Enter the following information:

Radius of circle:

7

Enter a Y if you would like to input more data

n

That’s all the information.

The output file contains the following:

Radius Area Circumference

5.00 78.54 31.42

4.00

50.27

25.13

7.00

153.94

43.98

Explanation / Answer

#include <stdio.h>

int main() {
//code
int i=0,n=0;
float rad[20], PI=3.14, area, circumference;
char c;
printf("Enter the following information: ");
do
{
scanf("%f",&rad[i]); // Getting input many Radius from User
scanf("%c",&c); // Getting character input , press Y to get more Radius
c = getchar();
getchar();
n++;
i++;
}while(c=='y'||c=='Y');
for(i=0;i<n;i++)
{
printf("Radius Area Circumference : ");
printf("%.2f",rad[i]); //printing RADIUS
area = PI * rad[i] * rad[i];
printf(" %.2f ",area); //printing AREA
circumference = 2 * PI * rad[i];
printf("%.2f ",circumference); //printing CIRCUMFERENCE
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote