Question
#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;
#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.224Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started