Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #define FILE_IN lab4.dat //define FILE_IN lab4sample.dat #define FILE_OUT lab4.out int main(void) { double radius, height, area, volume; int count; FILE * In;

image text in transcribed

#include

#include

#include

#define FILE_IN "lab4.dat"

//define FILE_IN "lab4sample.dat"

#define FILE_OUT "lab4.out"

int main(void)

{

double radius, height, area, volume;

int count;

FILE * In;

FILE * Out;

In = fopen(FILE_IN, "r");

if (In == NULL) {

printf("Error on opening the input file ");

}

Out = fopen(FILE_OUT, "w");

if (Out == NULL) {

printf("Error on opening the output file ");

}

fprintf(Out, "Name. Lab4. ");

while((fscanf(In, "%lf%lf", &radius, &height)) == 2) {

area = M_PI * radius * radius;

volume = M_PI * radius * radius * height;

count++;

fprintf(Out, " Cylinder %1d", count);

fprintf(Out, " The radius is: %9.3f", radius);

fprintf(Out, " The height is: %9.3f", height);

fprintf(Out, " The top area is: %9.3f", area);

fprintf(Out, " The volume is: %9.3f ", volume);

}

fclose(In);

fclose(Out);

return EXIT_SUCCESS;

}

for C

OUTPUT APPEARANCE (using lab4sample.out DEFINED Ruthann Biel. Lab 4. Cylinder 1 The radius is: The height is: The top area is: The volume is: 5.000 2.000 78.540 157.080 Cylinder 2 The radius is: The height is: The top area is: The volume is: 40.000 15.000 5026.548 75398.224

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

=+c) Show that C is perfect [A15].

Answered: 1 week ago