Question
c++ using a command line arguments program can be invoked with zero, one, or two program parameters. The first program parameter is the input file
c++
using a command line arguments program can be invoked with zero, one, or two program parameters. The first program parameter is the input file name. The second parameter is the output file name. Sample command lines together with corresponding actions by program p04 are shown below. Boldfaced type indicates data entered at the keyboard by the user.
example:
Enter the first input file name: i04.dat
Enter the output file name: o04.dat
--
File i04.dat contains values of for code fragment 4. Program p04 reads the input file and produces output for that file. The input file consists of a sequence of integers. Integers are separated by white space. White space is one or more characters from the set that includes a blank character, a newline character, or a tab character.
example of input file:
0 2 4 8 16 32 64 128 256
--
print program results to an output file.
1. Print a line identifying the code fragment. For example, this code fragment is identified as Code Fragment 4
2. Put your output in three columns. Label the first column n, the second column Analytical and the third column Empirical. Produce values of () for each code fragment. One line is printed for each value of read. Write the value of in the column labeled n. Write the value of () computed by the designated analytical function, af4, in the column labeled Analytical. Write the value of () computed by the selected empirical function, ef4, in the column titled Empirical. Right justify and align data produced in rows with their corresponding columns.
--
//function for af4
int af4(int n){return 2 + 4n + 2n.log2m}
//function for ef4
int ef4(int n){
int t=0;
int i = 0; t++;
while(i int m = n; t++; while(m>1){t++; m = m/2; t++; } t++; i++; t++ } return t; } --- //to double check ef4 and af4 are correct. fragment 4 analysis
Step 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