I code in RPG but recently took a software testing test with that included the following code:
n! = n*((n-1)!)
int f=1;
if (n<0){
fprintf(stderr, 'factorial; Negative argument.'n';
}else if ((n==0) ||(n==1)){
f=1;
}else {
f=n*factorial(-n);
}
return(f)
}
what does the statement: {else if ((n==0)||(n--1)){ mean? The question is what inputs represent test cases that would give decision coverage with the minumum number of test cases? The answer is -1, 1, 5. I understand the -1 and the 5 but not the positive 1. I thought the answer would be -1, 0, 5. I code in RPG not in C so I attributed my incorrect answer to my lack of knowledge of C. Any help would be much appreciated.
n! = n*((n-1)!)
int f=1;
if (n<0){
fprintf(stderr, 'factorial; Negative argument.'n';
}else if ((n==0) ||(n==1)){
f=1;
}else {
f=n*factorial(-n);
}
return(f)
}
what does the statement: {else if ((n==0)||(n--1)){ mean? The question is what inputs represent test cases that would give decision coverage with the minumum number of test cases? The answer is -1, 1, 5. I understand the -1 and the 5 but not the positive 1. I thought the answer would be -1, 0, 5. I code in RPG not in C so I attributed my incorrect answer to my lack of knowledge of C. Any help would be much appreciated.
Comment