Computer Science, asked by LavenderBlurr, 5 hours ago

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
Write the test cases to achieve 100% statement coverage, branch coverage and conditional coverage.

Answers

Answered by AnantThePro
0

Answer:

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

Write the test cases to achieve 100% statement coverage, branch coverage and conditional coverage.

Explanation:

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

Write the test cases to achieve 100% statement coverage, branch coverage and conditional coverage.

Similar questions