Consider the following program for calculating the factorial of a number. It consists of main( ) program and the module fact( ). Calculate the individual
cyclomatic complexity number for main( ) and fact( ) and then the cyclomatic
complexity for the whole program. Draw DD graph. List all independent
paths and design test cases from independent paths.
main()
{
int number;
int fact();
clrscr();
printf(“enter the number whose factorial is to be found out”);
scanf(“%d”, & number);
if (number < 0)
printf(“factorial cannot be defined for this number”);
else
printf(“factorial is %d”, fact(number));
}
int fact( int number )
{
int index;
int product=1;
for ( index=1; index<=number; index++)product=product*index;
return(product);
}
Share
0 Replies