Question: Exercise 2 : Code testing The source code in Figure 1 is a C implementation of an algorithm that takes a positive integer as input

Exercise 2: Code testing
The source code in Figure 1 is a C implementation of an algorithm that takes a positive integer as
input and returns an integer.
int discover( int number)
{
int i =0, j,digits[10];
while(number>=10)
{
digits[i++]=number%10;
number /=10;
}
digits[i]=number;
number=0;
for(j=0;j=i;j++)
{
number =number*10+digits[j];
}
return number;
}
(a) For number =5481, what will Discover
return. In general, what does the function
Discover do.
(b) Draw a flowchart( control-flow graph )
the code given in Figure 1
(c) Propose test cases that achieve branch
coverage.
(d) Propose test cases that achieve statement
coverage.
Exercise 2 : Code testing The source code in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!