Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. One approach to functional debugging is to collect input and output data for the software for typical input values. In particular we define a
5. One approach to functional debugging is to collect input and output data for the software for typical input values. In particular we define a set of input values, run the software, and record the output data generated by the software. In this exercise we will test the software using input values from 0 to N-1 where Nis 25. Consider the function sum (n) to test. The claim is that this function calculates the sum of the numbers N down to 1. For example sum (5) is 5+4+3+2+1 which equals 15. Furthermore, we will also test the hypothesis that the sum of N numbers can be expressed as the simple calculation of The test program will evaluate the function sum (n) and store the result in the array at sumBuf In]. We need to define a second function fun (n) that simply calculates (N(N+1))/2. We have another array funBuf that we will use to store the first 25 calculations of this second function. We will check in the p sumBuf to the elements of funBuf. The main function should set a flag value based on the outcome of this comparison. e main program for equivalence of the two functions b In a top-down approach, we place the main program on the top and the functions after. In this example we will configure the system as bottom up by placing the functions first and the main program at the end. Notice that bottom up organization does not need prototypes for the functions. Following C program template with code fragments are given to help you get started: #define TRUE 1 #define FALSE 0 #define N 25 /l array size unsigned long sum(unsigned long n) unsigned long partial, count unsigned long fun(unsigned long n) Page 3 of 4 int main(void) unsigned long num; unsigned long sumBufiNfunBufN: int correctFlag arrays to store computed values Write the C code with following functions: sum, fun) and main in a bottom-up layout in a single source code file as an embedded application. Note that function definitions precede the main function in a bottom-up layout and therefore not requiring function prototype declarations as given in the above template As a secondary method of verification for equivalence of two computations, use Keil/uVision to verify that sum (n) and fun (n) functions compute the same values by comparing values stored in the sumBuf and funBuf arrays using appropriate windows in the debugger
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