After considering the following program segment:
main() {
int number, index;
1. printf(“Enter a number”);
2. scanf(“%d, &number);
3. index = 2;
4. while(index <= number – 1)
5. {
6. if (number % index == 0)
7. {
8. printf(“Not a prime number”);
9. break;
10. }
11. index++;
12. }
13. if(index == number)
14. printf(“Prime number”);
15. } //end main
(a) Draw the Control Flow graph for the program.
(b) Calculate the cyclomatic complexity of the program using all the methods.
(c) List all independent paths.
(d) Design test cases from independent paths
(e) Write the test cases to achieve 100% statement coverage, branch coverage and conditional
coverage.
Attachments:
Answers
Answered by
0
Answer:
After considering the following program segment:
main() {
int number, index;
1. printf(“Enter a number”);
2. scanf(“%d, &number);
3. index = 2;
4. while(index <= number – 1)
5. {
6. if (number % index == 0)
7. {
8. printf(“Not a prime number”);
9. break;
10. }
11. index++;
12. }
13. if(index == number)
14. printf(“Prime number”);
15. } //end main
(a) Draw the Control Flow graph for the program.
(b) Calculate the cyclomatic complexity of the program using all the methods.
(c) List all independent paths.
(d) Design test cases from independent paths
(e) Write the test cases to achieve 100% statement coverage, branch coverage and conditional
coverage.
Similar questions
India Languages,
3 hours ago
Chemistry,
3 hours ago
Math,
6 hours ago
Chemistry,
8 months ago
English,
8 months ago