Details of this Paper

computer science




;;Here is the grading matrix where the TA will leave feedback. If you scored 100%, you will most likely not see any feedback J;Question;# points;Feedback;Max;Scored;1;Tracing;3;2;Testing;2;3;Refactoring;2;4;Debugging;3;Question #1 ? Tracing Programs;We are going to trace the following program, i.e. simulate in your head how it would execute on a computer. To help you, a trace table is provided for you to fill.;For each ?execution step? of the program, write down in the table the line being executed along with the value of each variable which was modified.;Please note that we omitted the usual main function definition and other #include statements. We assume the following fragment to be inside a main function.;Program to Trace;1 int something = 5;2 int data = 42;3 int n = 0;4;5 for(n = 0, data > 0, n++);6 data -= something;7 };8;9 if(data < 0) n--;Trace Table to Fill;Feel free to add / remove rows if necessary;Step #;Line #;Variables Values;Remarks;something;data;n;1;2;3;?;Question #2 ? Testing Programs;You are going to write tests for the following program fragment which we assume to be inside a main function. Its requirements are to;- Prompt the user for two int numbers X and Y;- If Y is zero the program should display ?Error #1? then exit.;- Otherwise, if any of the two input value is less or equal to zero, it should display ?Error #2? then exit.;- Otherwise, it should display how many times Y goes into X.;This is the equivalent of the integer division of X by Y.;Your objective is to write tests which will guarantee;- The program conforms to the requirements;- All possible execution paths have been tested;- Your program does not feature any errors;Program to Test;1 int div = 0;2 int data = 0;3 int n = 0;4 printf("Enter positive int to divide: ");5 scanf("%d", &&data);6;7 printf("Enter positive int to divide it by: ");8 scanf("%d", &&div);9;10 if(div == 0);11 printf("Error #1\n");12 exit(EXIT_FAILURE);13 };14;15 if((data <= 0) || (div 0, n++);21 data -= div;22 };23;24 if(data 0) && (grade 0) && (grade <=100));total += grade, number += 1;printf("Enter a grade between 0 and 100 inclusive: ");scanf("%d", &&grade);Summary of Improvements;Feel free to add rows to, or remove rows from, this table as needed;What did you modify;How did you modify it?;Why did you modify it?


Paper#65653 | Written in 18-Jul-2015

Price : $27