Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code in c. Just need lab4.c, need to get the same output lab4.c lab4.dat Write a program to compute the area of a parabola, with

code in c. Just need lab4.c, need to get the same output

image text in transcribedimage text in transcribedimage text in transcribed

lab4.c

image text in transcribed

lab4.dat

image text in transcribed

Write a program to compute the area of a parabola, with input data in one file, and output data in another file. A file, lab4.c, is provided with some of the print statements in it. The formula we will use is: area = 2LD Where: area = the area of a parabola 3 L = the length of the opening D = the depth of the parabola INPUT/OUTPUT DESCRIPTION: The input will be a file called lab4.dat. Each line or record of the file will consist of two numbers: the length and depth of a parabola. Use an fscanf statement in a while loop to repeatedly get each set of values. The output will be a file, lab4.txt, showing on each line, the length, depth, and area of a parabola. ALGORITHM DEVELOPMENT: Open the data file lab4.dat and do the appropriate error checking Open the output file lab4.txt and do the appropriate error checking Print your name and the column header lines needed while ((fscanf(..., &length, $depth)) == 2) | Compute the area of the parabola | print the length, depth, and area. I Print a final empty line. Close the two files DEFINED OUTPUT APPEARANCE: (showing only 2 of the expected 4 lines) Ruthann Biel. Lab 4. Data on Parabolas Length Depth Area 12.60 5.60 24.80 7.80 208.320 29.120 REMINDERS Include your name and Lab 4 in your comment block, and in your output. All numeric variables are to be double. The formula has implied multiplication which in C means, we must use the Some printf and fprintf statements are included in lab4.c for you. WARNING - VIEWING OUTPUT When you run the program, it will seem like nothing is happening. That is because the whole thing is going to lab4.txt. /* Your Name /* Lab 4 /* Figure the area of a parabola using files */ #include #include #define IN_FILE_NAME "lab4.dat" #define OUT_FILE_NAME "lab4.txt" int main(void) { double length, depth, area; FILE *infile; FILE *outfile; fprintf(outfile, " Your Name. Lab 4. "); fprintf(outfile, "Data on Parabolas "); fprintfoutfile, " Length Depth Area fprintf(outfile, "); "); fprintf(outfile, " "); return EXIT_SUCCESS; It 12.6 24.8 5.6 7.8 7.85 12.61 8.9 4.7

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

Students also viewed these Databases questions