Question: Implement the following functions: • RootCalculator(): This function estimates the Nth root of the positive number x by stepping through values y = 0.001,0.002, 0.003, and so on until yN > x. Then y is the estimated Nth root of x. Note that this iterative algorithm (brute-force search) yields an estimated Nth root with error tolerance equal to the step size of 0.001. NOTE: The use of the math library is not allowed in this question! It means that you have to calculate the root using a loop and not the pow() function. Dataln(): The function returns 0 if the file datain.txt does not exist. Otherwise, the function reads the content of the input file, assumed to be a sequence of real values, and stores them in an array. Finally the function returns the size of the array. Assume that there will be no more than 100 real values in the input file. • RootsArray(): This function takes an array of double precision values as an input argument and returns two arrays containing the square roots and cube roots of each input array element using the function RootCalculator(). • DataOut(): This function writes the program output (see example below) to an output file called dataout.txt. For example, if the input file datain.txt contains: 5.0 9.0 12.0 14.2 27.0 then dataout.txt must contain: square cube root root 5.00 1.71 9.00 3.00 2.08 12.00 3.46 2.29 14.20 3.77 2.42 27.00 5.20 3.00 Copy and paste your program into the box below.
Question: Implement the following functions: • RootCalculator(): This function estimates the Nth root of the positive number x by stepping through values y = 0.001,0.002, 0.003, and so on until yN > x. Then y is the estimated Nth root of x. Note that this iterative algorithm (brute-force search) yields an estimated Nth root with error tolerance equal to the step size of 0.001. NOTE: The use of the math library is not allowed in this question! It means that you have to calculate the root using a loop and not the pow() function. Dataln(): The function returns 0 if the file datain.txt does not exist. Otherwise, the function reads the content of the input file, assumed to be a sequence of real values, and stores them in an array. Finally the function returns the size of the array. Assume that there will be no more than 100 real values in the input file. • RootsArray(): This function takes an array of double precision values as an input argument and returns two arrays containing the square roots and cube roots of each input array element using the function RootCalculator(). • DataOut(): This function writes the program output (see example below) to an output file called dataout.txt. For example, if the input file datain.txt contains: 5.0 9.0 12.0 14.2 27.0 then dataout.txt must contain: square cube root root 5.00 1.71 9.00 3.00 2.08 12.00 3.46 2.29 14.20 3.77 2.42 27.00 5.20 3.00 Copy and paste your program into the box below.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
in C

Transcribed Image Text:Question: Implement the following functions:
• RootCalculator(): This function estimates the Nth root of the positive number x by stepping
through values y = 0.001,0.002,0.003, and so on until yN > x. Then y is the estimated Nth
root of x. Note that this iterative algorithm (brute-force search) yields an estimated Nth root
with error tolerance equal to the step size of 0.001. NOTE: The use of the math library is not
allowed in this question! It means that you have to calculate the root using a loop and not the
pow() function.
• Dataln(): The function returns 0 if the file datain.txt does not exist. Otherwise, the function
reads the content of the input file, assumed to be a sequence of real values, and stores them in
an array. Finally the function returns the size of the array. Assume that there will be no more
than 100 real values in the input file.
• RootsArray(): This function takes an array of double precision values as an input argument and
returns two arrays containing the square roots and cube roots of each input array element using
the function RootCalculator().
• DataOut(): This function writes the program output (see example below) to an output file called
dataout.txt.
For example, if the input file datain.txt contains:
5.0
9.0
12.0
14.2
27.0
then dataout.txt must contain:
square
cube
root
root
5.00
2.24
1.71
9.00
3.00
2.08
12.00
3.46
2.29
14.20
3.77
2.42
27.00
5.20
3.00
Copy and paste your program into the box below.
![#include <stdio.h>
#define MAXLN 100
void RootCalculator(double number, double N, double tol, double* ptr_root);
int DataIn(FILE* input_file, double* ptr_array);
void RootsArray(double* ptr_array_1, double* ptr_array_2,
double* ptr_array_3, int size_array, double tol);
void DataOut(FILE* output_file, double* ptr_array_1,
double* ptr_array_2, double* ptr_array_3, int size_array);
int main(void)
double tolerance = 0.001;
double input_array[MAXLN];
double square_root[MAXLN];
double cube_root[MAXLN];
int array_size;
fopen ("datain.txt", "r");
fopen ("dataout.txt", "w");
FILE* fin =
FILE* fout =
array_size = DataIn(fin, input_array);
RootsArray (input_array, square_root, cube_root, array_size, tolerance);
DataOut (fout, input_array, square_root, cube_root, array_size);
fclose(fin);
fclose (fout);
return 0;
}
/* Implement the functions here */](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0ea15aad-ce09-44c1-ae1a-fd69c581a5af%2F4bb8d6e4-5499-419a-b05c-06bc4b41a46a%2Fq6u4zj_processed.png&w=3840&q=75)
Transcribed Image Text:#include <stdio.h>
#define MAXLN 100
void RootCalculator(double number, double N, double tol, double* ptr_root);
int DataIn(FILE* input_file, double* ptr_array);
void RootsArray(double* ptr_array_1, double* ptr_array_2,
double* ptr_array_3, int size_array, double tol);
void DataOut(FILE* output_file, double* ptr_array_1,
double* ptr_array_2, double* ptr_array_3, int size_array);
int main(void)
double tolerance = 0.001;
double input_array[MAXLN];
double square_root[MAXLN];
double cube_root[MAXLN];
int array_size;
fopen ("datain.txt", "r");
fopen ("dataout.txt", "w");
FILE* fin =
FILE* fout =
array_size = DataIn(fin, input_array);
RootsArray (input_array, square_root, cube_root, array_size, tolerance);
DataOut (fout, input_array, square_root, cube_root, array_size);
fclose(fin);
fclose (fout);
return 0;
}
/* Implement the functions here */
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 5 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education