Computer Science, asked by LavenderBlurr, 6 hours ago

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 bosechse
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