T2COSC2437CSSp2021

docx

School

Sam Houston State University *

*We aren’t endorsed by this school

Course

2347

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

29

Uploaded by PrivateCrocodile3673

Report
COSC2347 “C” with Linux Test 2 Spring 2022 Burris Answer three of the following including question one. Number your questions on the answer sheets in ascending numeric order from one through five inclusive. Clearly write “delete” on the answer sheets by the two questions you do not wish graded. Leave at least a one-inch margin at the top of every page. Do not write on the back of pages. Staple your answer sheets (in ascending numeric order) on top of the test in the upper left corner. Write your name in the upper right corner of the answer sheets (first page). Turn the stapled bundle over and write your name in the upper righthand corner on the back of the test. All answers must be placed on the answer sheets. No credit will be awarded for work appearing on the test. A five-point Road Map Fee (RMF) will be deducted for each instance of failure to follow instructions. You will not receive credit for material I cannot read (illegible) or that is obstructed from my view, e.g., by a staple. You may only use standard GNU “C” unless the question specifically requires C++. Warning: There are no “short” answers on this test. Tell me everything germane to the topic. If you cannot write a page of relevant information, you may wish to consider another question . You should be able to comfortably answer every question. Please review any material after the test you feel requires more attention. 1) Create the executable “withHoldings” in the “Home Directory” using the “C” files in the “Federal Tax”, “Insurance” and Family Insurance Benefits directories using a “make” file. Files not modified since the last time the executable was created should not be recompiled. Utilize “chain rules properly in conjunction with the directory structure. Do not use the “CLEAN” directive. The “Family Insurance Benefits” directory is a subdirectory of “Insurance Directory.” FederalTaxDirectory FICATax.c Medicare.c MediCare.c HomeDirectory Make or script withHoldings InsuranceDirectory EmployeeLifeInsurance.c EmployeeHealthInsurance.c FamilyInsuranceBenefits Directory FamilyHealthInsurance.c FamilyLifeInsuranc 1
2) Choice (do only one of the following): A) Discuss “deadlock” in detail with an example. Be sure to list and explain the four basic conditions present in deadlock. B) Discuss “race conditions” in detail with an example. What is the general approach to prevent race conditions. 3) Compare and contrast anonymous pipes, named pipes and sockets in detail. Be sure to state the circumstances under which each is most appropriate. 4) Draw a flow chart to solve the group control break problem with respect to departments posed in lab 2. Utilize diamonds, trapezoids and rectangles correctly to express questions, I/O and logic operations respectively. 5) When “C” creates a child process what does the child get, if anything, from the parent process? Under what circumstances may the same physical data be accessed by the parent and child? When may it not be shared? What does the “C” runtime environment do if improper shared access is attempted to prevent race conditions? What are the penalties? 2
6) Solve the problem 1’ using a script in the “HomeDriectory.” Be sure the script is executable. 1) Draw a flow chart to solve the group control break problem with respect to departments posed in lab 2. Utilize diamonds, trapezoids and rectangles correctly to express questions, I/O and logic operations respectively. 2) Convenience me you read the assignment (“To Transform to Have Agility, Don’t Do a Capital A, Capital T Agile Transformation) in great detail. 3) Explain the “Trojan Horse” horse problem. You must include at least 2 of the 3 reasons Call-by-Value (CBV) was added to “C” and other programming languages. 4) Write a function to compute the value of the following series to 3 digits accuracy to the right of the decimal point using a minimum number of terms to obtain the answer. You may use a type 1 or 2 function using double precision arithmetic for all intermediate operations (no integer arithmetic). Hint: Epsilon = 0.0001 N = 10000 ∑ (2*K) / K 2 = (2 * 1) / 1*1 + (2*2)/ (2*2) + (2*3)/(3 * 3) +…+ 2*10000 / 10000 2 K = 1 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
5) Choice (do only one of the following): 7) Create the executable “withHoldings” in the “Home Directory” using the “C” files in the “Federal Tax” and “Insurance” directories using a “make” file. Files not modified since the last time the executable was created should not be recompiled. Utilize “chain rules properly in conjunction with the directory structure. Do not use the “CLEAN” directive. The “FamilyInsuranceBenefits” directory is a subdirectory of “Insurance directory.” 8) Solve the problem in part ‘a’ using a script in the “HomeDriectory.” Be sure the script is executable. FederalTaxDirectory FICATax.c Medicare.c MediCare.c HomeDirectory Make or script withHoldings InsuranceDirectory EmployeeLifeInsurance.c EmployeeHealthInsurance.c FamilyInsuranceBenefits FamilyHealthInsurance.c FamilyLifeInsuranc 6) We proposed alternate designs for the “B” option of lab 2 (Top-Down-Iterative Refinement and Dynamic Data Flow Analysis [used 2 separate programs for group control breaks and page breaks]). Explain the potential advantages/disadvantages of the two designs with respect to use of computer resources (space and execution time). Which potentially provides the best utilization of personnel over time and why? Which of the approaches offers the best chance for reuse and reduction in maintenance/modification cost in future projects and why? DO NOT consider program inversion. If you are the manager, which design would you select? 4
7) Indicate what is printed on the answer sheet in the order the statements are executed. #include <stdio.h> void add1( int i ); void add2(int *i); int j = 5, k = 3, c = 10; int main( ) { int j = 3; int k = 7; printf("In the main j = %d\n", j); add1( j ); printf( "In the main j = %d\n", j); add2( &j ); printf("In the main j = %d \n", j); printf("In Main k = %d \n" , k); add1( k ); printf("In the main k = %d \n", k); } void add1(int i){ int k = 10; i++; i += k; printf("In add1 i = %d \n", i); } void add2(int *i){ int k = 10; *i++; *i += k + c; printf("In add2 i = %d \n", *i); } 8) Implement the function char *strcat( char *first, char *second ). You may utilize string functions covered in class. 5
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
9) UNIX systems utilize a process name “copy-on-write.” Explain how the process works and its motivations in detail. 10) Compare and contrast the advantages of scripts and the make utility for creating executables in UNIX. Be sure to explain any advantages and why they are advantages. 11) When using a hill climbing or greedy algorithm in “C” programers must face the fact the hardware will suffer from a fixed word length. Explicitly explain how the programmer can tell when the current answer is accurate to at least 3 digits to the right of the decimal point. Include a line or lines of “C” code to demonstrate the technique. 12) Explain the “trojan horse” as applied to “C.” What causes the problem and how does “C” solve or at least mitigate the problem. 13) Discuss “deadlock” in detail. Be sure to list and explain the four basic conditions present in deadlock. 14) “C” supports anonymous pipes, named pipes and sockets. Explain in detail when each method should be used. How does each of these communications methods differ from the others? 15) Write a program to implement a denial of service attack using the fork command in “C.” Clearly identify the parent and child code in your solution. 16) Write a section of code to execute the program “gotcha” using the “execlp” command in “C.” “gotcha” is located in the directory nohope/itHurts/pain and requires 3 command line parameters p1, p2 and p3. How and why would a Black Hat DF major/bad hacker desire and utilize this command? 17) 18) We are nearing the shipping date for our new game software. The graphics and code base have far exceeded our size expectations. Working with Beta testers we have determined functions 1 through 8 and 24 through 33 are in constant use by all gamers in the system and available in standard “C” libraries all gamers will have on their systems prior to the purchase of our game software. Functions 9 through 16 are not always used but critical to performance. They must be in memory and available instantly when referenced. Unfortunately, they are game specific and will not be in any user’s system libraries prior to purchasing our software. The rest of the software may or may not be referenced in a game. We desire to minimize the amount of memory utilized in the game for all users (foot 7
print). Users always need to pause and consider their best strategy prior to selecting the path represent by the remaining functions. 19) prior to continuing play. State the most efficient way to provide the software functionality to our gamers while minimizing main memory requirements and critical delays for loading using libraries. You must explicitly state which functions should be in each library and why the type of library selected is the best for the listed software. We also desire to limit the size of the software shipped . 20) Create a shared library for the international space station named “SpaceLib” from programs “doc.c,” “unDoc.c,” “openHatch.c,” and “closeHatch.c.” Be sure to follow all naming conventions utilized by GNU and discussed in class. Now compile the program “dockAtStation.c” which references the shared library and execute the result. All programs were written using GNU standard “C.” You may assume the source code for the library and main program are in the current directory or system path during the process of creating the executable. Be sure to set any required environment variables . 21) Explain the typical role of a header file in “C” with respect to code included from libraries during the translation process. What problems would you expect if the header file is not included in the code? Explain. 22) Assume the existence of a dynamic library named “SpaceLib ” containing the programs “doc.c,” “unDoc.c,” “openHatch.c,” and “closeHatch.c.” Write a short (skeleton) program in GNU “C” to invoke the library modules openHatch and closeHatch using handles appropriately . You need not print results or perform other tasks. Translate and execute your program from the command line . You may assume the source code for the main program and the library are in the current directory or system path during the process of creating the executable. You must properly set any environment variables required to reference the library . 23) Compile and link the modules payroll/main.c, ficaTax.c, payroll/withHoldingTax.c, and report.c creating the executable “payroll” using a script. 24) Compile and link the modules payroll/main.c, payroll/ficaTax.c, payroll/withHoldingTax.c, and payroll/report.c creating the executable “payroll” using a “make” file. Files not modified since the last time the executable was created should not be recompiled . 25) Explain in detail the difference between call-by-reference (CBR) and call-by- value (CBV). When should each be used? 26) In general text files may not be used initially as a “scripts” on a Linux system. Exhibit the statement or statements required to make the text file “CreateExecutable.sc” an executable script file. 8
27) Write a type 1 or type 2 function to “efficiently” calculate the following series. We will consider the solution sufficiently accurate whenever the difference between two successive iterations is less than 0.0001. Use double precision for arithmetic. We assume terms in the series approaching K/N exceed the accuracy (capability) of our computer. N Σ K/J = K/1 + K/2 + K/3 + … where K is a double. J and N are integers. J = 1 28) Explain the “Trojan Horse” with respect to computing including the 3 reasons call- by-value (CBR) was added to the language. 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
29) Explain the Trojan Horse problem with respect to programming languages in detail (malicious, accidental, destruction of literals like 12, passing array (structured types) ). Now explain in detail the roles played by call-by-value (CBV) and call-by-reference (CBR). 30) *Create a static library for the international space station named “SpaceLib” from programs “doc.c,” “unDoc.c,” “openHatch.c,” and “closeHatch.c.” Be sure to follow all naming conventions utilized by GNU and discussed in class. Now compile the program “dockAtStation.c” which references the static library and execute the result. All programs were written using GNU standard “C.” You may assume the source code for the library and main program are in the current directory or system path during the process of creating the executable. Be sure to set any required environment variables 10
Test 2 covers static, shared and dynamic link libraries. You must master type 1 and 2 function in both “C” and “C++” including standard programming convention (both those enforced and not enforced by the compiler) CBR and CBV are emphasized with respect to communicating information between programs including potential problems such as the Trojan Horse. Numerical techniques to prevent errors or attain maximum accuracy when determining results due to round off errors, conversion errors, and truncation errors are considered with respect to radix and restrictions on the number of 31) Exhibit the statements to create a static library named “SpaceLib” from programs “doc.c,” “unDoc.c,” “openHatch.c,” and “closeHatch.c.” You must compile the modules prior to placing them in the library checking for warning messages. Be sure to follow all naming conventions utilized by GNU and discussed in class. Now compile the program “dockAtStation.c” which depends on the shared library and execute the result. Remember to include any required environment settings required for execution . All programs were written using GNU standard “C.” You may assume the source code for the library and main program are in the current directory or system path during the process of creating the executable. bits in the unit of storage. 32) Assume the existence of a dynamic library named “SpaceLib ” containing the programs “doc.c,” “unDoc.c,” “openHatch.c,” and “closeHatch.c.” Write a short (skeleton) program in GNU “C” to invoke the library modules openHatch and closeHatch using handles appropriately . You need not print results or perform other tasks. Translate and execute your program from the command line . You may assume the source code for the main program and the library are in the current directory or system path during the process of creating the executable. You must properly set any environment variables required to reference the library . 11
K = Max 33) We need to compute the series ∑ Beta/K to maximum accuracy starting with K = 1 Beta/1 + Beta/2 + Beta/3 + ο ο ο + Beta/Max. using double precision arithmetic and a type 2 function . The value Max and Beta must be passed by value and the result returned by reference using standard “C” only. “Max” is an integer and “Beta” a double precision number. Unfortunately the value of Beta/K as K approaches Max appears to be machine dependent and linked to the number of bits in a double precision number. We have decided that if two successive iterations (Iter K and Iter K+1) differ by no more than 0.0001 we will accept the result as sufficiently accurate for our purposes. Write the type 2 function using standard “C” code (no C++ will be accepted) to accomplish this goal. Note this technique has been used by language translator writers to implement math libraries in just about every programming language and operating system in existence for anything that can be expressed as the sum of an infinite or very large series including sin, cos, tan, logarithms, PI and related values. Do not write the complete main program . You must however declare the call parameters in the main program and exhibit the code in the main program to invoke your type 2 function . 34) *To remain employed, you must implement a type 1 function to determine the surface area of a rectangular solid of height “ht” and end with dimensions “ln” for length and width “wd,” i.e., ( (ln * wd * 4) + (wd * ht * 2 ) ). The variables ln and wd must be passed by value. The variable ht must be passed by reference. Now write a skeleton main program to declare and pass the parameters to the function printing the result. You may only use standard GNU “C ++” (not “C”). 35) *Repeat question 2 using a type 2 function. 36) Given the following section of code implementing the Newton-Raphson Method, explain how the test “!( fabs( guess * guess – n) < EPSILON” works. You must clearly explain why it is coded in this manner. // #define EPSILON 0.000001 // Traditional constant definition. const double EPSILON = 0.000001; // New constant definition. double sqrt( double n) { double guess; if (n >= 0.0) { //verify legal input for (guess = n; 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
!( fabs(guess * guess – n) < EPSILON); guess = ( ( n + guess * guess) / (2.0 * guess) ) ) /* null body for loop */ ; return(guess); } else return (-1.0); //error flag } 37) Explain the Trojan Horse problem with respect to programming languages in detail and its solution. 38) To remain employed, you must implement a type 1 function to determine the volume of a cylinder using the formula πr 2 h where r is the radius of the base and h is the height of the cylinder. The base of the cylinder must be passed by value (CBV) and the height by reference (CBR) using standard “C” (not C++). Now write a skeleton main program to demonstrate your function works properly. You may only use standard GNU “C” (no C++). 39) To remain employed, you must solve question 2 using a type 2 function. The base and height must be passed through the parameter list by value (CBV) and the area returned through the parameter list by reference (CBR). Write a skeleton main program to call the function and print the area. You must use C+ + parameter passing conventions to receive full credit. 40) Compare and contrast static, shared, and dynamic libraries. An extensive discussion of the advantages and disadvantages of each approach is expected. 41) Create a shared library named “StatLib” from programs “std.c,” “avg.c,” and “mean.c.” Be sure to follow all naming conventions utilized by GNU and discussed in class. Now compile the program “hope.c” which depends on the shared library and execute the result. Remember to include any required environment settings required for execution . 42) Exhibit the statements to create a static library named “statLib” from programs “std.c,” “avg.c,” and “mean.c.” You must compile the modules prior to placing them in the library checking for warning messages. Now exhibit the command to compile and execute a program in file “hope.c” which utilizes statLib . You may assume the source code and the library are in the current directory or system path during the process of creating the executable. You must properly set any environment variables referencing the library. 43) Assume the existence of a dynamic library named “statLib ” containing the functions “double std( int grades[ ], int n)” and “double avg( int grades[ ], int n )” where grades is an array of n grades. Write a short (skeleton) program in GNU “C” to invoke the library modules using handles appropriately . You need not print results or perform other tasks. Translate and execute your program from the command line . You may assume the source code and library are in the current 13
directory or system path during the process of creating the executable. You must properly set any environment variables required to reference the library . 9) Assume a function defined as follows by the project manager in standard “C.” Write the complete function to calculate and return the average and standard de- viation of data in the array. Write a single line of code in the main program to in- voke the function if the grades are in an array COCS2437, there are 42 grades, and the class average and standard deviation should be returned in the variables classAverage and classSTD in the main program. void stats( int grades[ ], int ngrades, *avg, *std); Pre-condition: receive array of grades, and number of grades. Post-condition: return the average and standard deviation of the grades 14
44) Exhibit a “Makefile” in the project directory to create the executable “payroll” dependent on all files in both the “Src1” and “Src2” directories. All object files should be created in the source directories where the corresponding “C” file is located. The object files should remain in the respective source directory. In the future, if a single or subset of source files are modified, we do not desire to have to recompile all source files prior to linking. For convenience, I have shown the executable and object files in the directories where they should be created. Project Directory Makefile payroll Src1 Directory Src2 Directory payrollMain.c payrollMain.o calGross.c calGross.o payrollHeader.h ficaTax.C ficaTax.o fedWithHoldingTax.c fedWithHoldingTax.o 15
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
10) Indicate what is printed by the following code in the space provided. #include<stdio.h> void add1( int i ); void add2( int * i ); int j = 4; float m = 6.6; int main( ) { int j = 3; double k = 6.98; add1( j ); printf("\nIn the main j = %d\n", j); // j = __________________ add2( & j ); printf("\nIn the main j = %d\n\n", j); // j = __________________ add1( k ); printf("\nIn the main k = %f\n", k); // k = __________________ printf("\nIn the main m = %f\n", m); // m = _________________ } void add1(int i){ int k = 10; i++; i += k + j; printf("\nIn add1 i = %d C-B-V", i); } void add2( int * I ) { int k = 10; ( * i)++; * i += k; printf("\nIn add2 i = %d C-B-R", *i); m = *i * 2.0; } 16
45) Explain in great detail how to create a static library and the options “cru.” Your discussion must include an explanation of the naming conventions used by GNU in working with user defined static libraries (hint: prefix and post fix). Given the following section of code implementing the Newton-Raphson Method, explain how the test “!( fabs(guess * guess – n) < EPSILON” works. You must clearly explain why it is coded in this manner. // #define EPSILON 0.000001 // Traditional constant definition. const double EPSILON = 0.000001; // New constant definition. double sqrt( double n) { double guess; if (n >= 0.0) { //verify legal input for (guess = n; !( fabs(guess * guess – n) < EPSILON); guess = ( ( n + guess * guess) / (2.0 * guess) ) ) /* null body for loop */ ; return(guess); } else return (-1.0); //error flag } 17
I n preparing for test two remember we covered several loop control statements, nested “if’s,” the ternary operator and “case” structure. We also covered type 1 and 2 func- tions, call-by-value and call-by-reference. Only standard “C” will be allowed on the test, “NO C++.” Next we covered a number of laws and research from the field of Software Engineering motivating program/language and design concepts. Finally we covered creation and use of static, shared, and dynamic link libraries, both theory and code. At least 3 of the test questions/option require detailed discussion. Expect to write more than a page of information to satisfy a discussion question. I would classify at least 4 questions as heavily dependent on use of GNU Linux command line instructions. For credit, please limit yourself to instructions covered in class! Expect to write functions utilizing the “C” instructions covered for this test and methods for parameter passing. The instructions for the test follow: CS278 “C” Test 2 Spring 2010 Burris Answer any five of the following 7 questions! Number your questions on the answer sheets in ascending numeric order from one through seven inclusive. Clearly write “delete” on the answer sheets by the two questions you do not wish graded. Leave at least a one-inch margin at the top of every page. Start each question you answer on a new page. You may however delete more than one consecutive question on the same page. Do not write on the back of pages. Staple your answer sheets (in ascending numeric order) on top of the test in the upper left hand corner. Write your name in the upper right hand corner of the answer sheets (first page). Turn the stapled bundle over and write your name in the upper right hand corner on the back of the test. All answers must be placed on the answer sheets. No credit will be awarded for work appearing on the test. A five point Road Map Fee (RMF) will be deducted for each instance of failure to follow instructions. You will not receive credit for material I cannot read (illegible) or that is obstructed from my view, e.g., by a staple. You may only use standard GNU “C” (no C++). Warning: There are no “short” answers on this test. Tell me everything germane to the topic. Your performance is being compared to all other members of the class. . If you cannot write a page of relevant information, you may wish to consider another question . From a professional standpoint, you should be able to address every question on the test. Please go back and master any material you feel needs work. %%%%%%%% The department has two candidates for faculty position next week. To accommodate my responsibilities, I need to adjust my office hours for the week as follows based on currently available information. Monday: 12:45 - 2:30 Tuesday: none Wednesday: 1-2:30 Thursday: 2-2:50 18
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Friday none Dr. B 9) Discuss the “Trojan Horse” problem in detail and how when properly utilized, “C” helps to ameliorate the problem. Hymnal page 118: Trojan Horse 19
10) Assume the following directory structure. We wish to create the executable “payroll” in the ProjPayRoll directory. The executable is dependent on payrollMain.o, calGross.o, and calTx.o. calTax.o is dependent on calFed.o and calState.o. dir ProjPayroll dir dir dir PayrollMain Gross Tax payrollMain. c calGross.c calTax.c calFed.c calState.c Exhibit a script created using a text editor (e.g., vi or vim) name createPayroll in the project directory to create the executable “payroll.” The script createPayroll executable in the project directory. Note the script will not be executable immediately after creation with the text editor. As part of your answer, exhibit the command required to make the script executable. $vim buildPayroll # script to build payroll gcc -c PayrollMain/payrollMain.c –o PayrollMain/payrollMain.o gcc -c Gross/calGross.c -o Gross/calGross.o gcc –c Tax/calFed.c -o Tax/calFed.o gcc –c Tax/calState.c –o Tax/calState.o gcc –c Tax/calTax.c –o Tax/calTax.o gcc –o payroll PayrollMain/payrollMain.o Gross/calGross.o Tax/calFed.o Tax/calState.o Tax/calTax.o $chmod +x buildPayroll 11) Solve problem 6 using a Makefile. $vim Makefile payroll: payrollMain.o calGross.o calTax.o calFed.o calState.o <tab> gcc –o payroll payrollMain.o calGross.o calTax.o calFed.o calState.o payrollMain.o: PayrollMain/payrollMain.c <tab> gcc –c –o payrollMain.o PayrollMain/payrollMain.c calGross.o: Gross/calGross.c <tab> gcc –c –o calGross.o Gross/calGross.c calFed.o: Tax/calFed.c <tab> gcc -c -o calFed.o calFed.c calState.o: Tax/calState.c 20
<tab> gcc -c -o calState.o calState.c calTax.o: Tax/calTax.c <tab> gcc -c -o calTax.o calTax.c clean: <tab> rm *.o payroll I would have preferred to see use of SRC_FILES, patsub, %.o:%.c, etceteras. 12) To remain employed, you must implement a type 1 function to determine a student’s letter grade based on their numeric grade. If the numeric grade greater than or equal to 85 the student should receive an “A.” If the numeric grade is less than 85 but greater than or equal to 75 they should receive a grade of “B.” Grades above 65 but below 75 should receive a letter grade of “C.” Students making a grade 65 or less must receive an “F.” The type 1 function should accept the numeric grade as an integer by value (CBV) and use a “return” statement to return the letter grade. Now write a skeleton main program to demonstrate your function works properly. You may only use standard GNU “C” (no C++). You must implement the type 1 function using a “nested if.” 13) To remain employed, you must solve question 2 using a type 2 function. The numeric grade must be passed through the parameter list by value (CBV) and the letter grade returned through the parameter list by reference (CBR). The letter grade must be determined using a nested ternary operator in the function. 21
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Scratch while creating test 2. 14) Our accounting department has supplied the following logic for computing FICA tax. The FICA Limit is currently $97,000 and the FICA Rate is 6.78%. no yes Ytd >= 97,000 Pay no tax no yes Ytd + gross <= 97,000 Pay tax on total gross Pay tax only on (97,000 – ytd) In a properly drawn flow chart, all questions (contain a relational or logical operator) should be in diamonds. The double rectangles have been substituted above for diamonds by the accounting department. Write code to compute FICA tax twice. First use a nested “if” statement. Second use a nested ternary operator . Hint: <Boolean expression> ? <true statement> : <false statement> Section 1 (you must select at least one question from this section) : 1) Explain in detail the difference between static and dynamic link libraries in GNU “C/C++.” Emphasize the advantages and disadvantages of each. 2) Choice (do only one of the following): 22
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A) Assume the existence of hope.h and hope.c. The file hope.c contains the following functions: void pray(int howHard, int goal, int *answer); int kneePads( int size); float pay( float hours); Exhibit the instructions to create a dynamic link library named “hopeDLL” following GNU naming conventions. After creating the library exhibit the commands to create the executable for the file myPrayer.c referencing functions in the shared library. B) Write a header file hope.h containing function prototypes for the functions in hope.c. Use must use conditional compilation statements to make sure the prototypes are not multiply defined. Hint: ifdef K = Max 46) We need to compute the series ∑ 1.0/K to maximum accuracy. K = 1 Unfortunately the value of Max appears to be machine dependent and linked to the number of bits in a double precision number. We have decided that if two successive iteration Iter K and Iter K+1 differ by no more than 0.00000001 we will accept the result as sufficiently accurate for our purposes. Write the “C” code to accomplish this goal. Note this technique has been used by language translator writers to implement math libraries in just about every programming language and operating system in existence for anything that can be expressed as the sum of an infinite or very large series including sin, cos, tan, logarithms, PI and related series. 23
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3) Assume you have created the dynamic link library required for question 2. Write a section of GNU “C” code to open the dynamic link library of question 2 and print the value returned by function kneePads( mySize ) where “mySize” is equal to 45. Release the library when finished. 15) Assume the directory Home with subdirectories Main and Helper containing files as shown. Main takeTest.c Home mySc ript takeT est Helper void pray(int howHard, int goal, int *answer); in file pray.c int kneePads( int size); in file kneepads.c float pay( float hours); in file pay.c Write the script “myScript” to create the executable “takeTest” in the Home directory. Your script should create and leave all object files ( .o ) in the same directory as their source files. 16) Solve problem 4 using a Makefile leaving the object files in the same directory as their source files. 17) Choice (do only one of the following): A) Clearly explain the difference between conversion, round off, and truncation errors with examples of each. B) Discuss the “Trojan Horse” problem in detail. How does “C/C++” solve or at least ameliorate the problem? You must be specific to receive credit. C) Explain Heising’s 80/20 rule in detail. Now explain in detail how you would incorporate this knowledge in problems involving a nested “if” statement. 1) Choice (do only one of the following): 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A) First state Miller's Law. You must explain the inference made by Miller based on his research. Now explain in detail how Miller's Law is applied to program development. B) First state Graicunas Law. You must explain the inference made by Graicunas with respect to management based on his research. How did he propose to mitigate the exponential influence predicted by his equation. Finally (most important), explain in detail how Graicunas Law is applied to either data or control in software development. 25
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Section 2 (you must select at least one question from this section) : 18) Given the declaration below, implement the function to return the product of the integers in the array p1. void sumIt( int p1[ ], int numRec, int *ans) 26
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
9) Given the following section of code, explain how the test “!( fabs(guess * guess – n) < EPSILON” works. You must clearly explain why it is coded in this manner. // #define EPSILON 0.000001 // Traditional constant definition. const double EPSILON = 0.000001; // New constant definition. double sqrt( double n) { double guess; if (n >= 0.0) { //verify legal input for (guess = n; !( fabs(guess * guess – n) < EPSILON); guess = ( ( n + guess * guess) / (2.0 * guess) ) ) /* null body for loop */ ; return(guess); } else return (-1.0); //error flag } I have made the first pass to create Test 2. Test 2 covers all material covered in class since the first test including program design (e.g., Millers Law), libraries (static, shared, dynamic), functions and parameter passing (C/C++), precision (truncation etcetera), and basic arrays if we get that far prior to the test. 47) Choice (do only one of the following): A) In class we discussed the principal of “Divide and Conquer” with respect to software design. Explain how Miller’s Law and Graicunas’ Law apply including the argument for designing and implementing minimum cost software. B) Given the following section of code implementing the Newton-Raphson Method, explain how the test “!( fabs(guess * guess – n) < EPSILON” works. You must clearly explain why it is coded in this manner. // #define EPSILON 0.000001 // Traditional constant definition. const double EPSILON = 0.000001; // New constant definition. double sqrt( double n) { double guess; if (n >= 0.0) { //verify legal input for (guess = n; !( fabs(guess * guess – n) < EPSILON); guess = ( ( n + guess * guess) / (2.0 * guess) ) 27
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
) /* null body for loop */ ; return(guess); } else return (-1.0); //error flag } C) Computers are subject to truncation, conversion, and numeric errors due to their finite precision. Explain each error in detail. D) Explain the Trojan Horse problem with respect to programming languages in detail and its solution. 48) Answer all of the following: A) We are nearing the shipping date for our software. The graphics and code base have far exceed our size expectations. Fortunately approximately 90% of the material included from libraries is part of every standard Linux system. The standard Linux system libraries may be used as shared or dynamic link libraries. That leaves about 10% of the library code that must be shipped with the system. To obtain the response time expect by our users, we desire all the base and library code to be loaded when the system is placed in main memory (prior to the start of execution). State a strategy to solve this problem and support why it is the best! B) We are nearing the shipping date for our software. The graphics and code base have far exceed our size expectations. Fortunately approximately 90% of the material included from libraries is part of every standard Linux system. The standard Linux system libraries may be used as shared or dynamic link libraries. That leaves about 10% of the library code that must be shipped with the system. Beta testing has shown the response time for our software to far faster than customer expectations. However the beta testers are complaining about the size of the main memory footprint if all program and library code are loaded prior to the start of execution. We have noted users typically only use about 17% of the library routines from code existing in the libraries common to all Linux installations and those libraries we intend to ship with the system during a single usage of the program. However, the same 5% of library code in the library routines we ship with the system consume 50% or more of the CPU time. State a strategy to minimize space utilization while ensuring the fastest user response time possible. You must support your strategy on technical grounds to receive full credit. State a strategy to solve this problem and support why it is the best! C) The point-of-sale (POS) software normally accepts input from the keyboard and prints results to the screen. The system crashed 28
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Wednesday evening but fortunately we have a full backup from the weekend. “IT” has suggest loading the system from the full backup on a new disk drive. Unfortunately that will not contain the transactions between the backup and the time the system crashed. It turns out IT had an auditing program running all week that record all transaction from the backup to the crash. After loading the backup, they plan to have the POS software, “pos,” process the data form the transaction file in the current directory named “Tran.dat” and print all results that would have been printed on the screen to a file “restored” using I/O redirection. That way we will have a hard copy from which any disputes over transactions having been processed can be resolved. Exhibit the Linux command or commands to accomplish this goal executing the program “pos” at the command line. 29
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help