Statement coverage and unreachable code
Task 1
Show1. examplesReturn ofStatement unreachableBefore codePrint basedStatement
#include on<stdio.h>
int https://www.geeksforgeeks.org/c-program-to-show-unreachable-code-error/main()
{
printf("text_1");
return 0;
printf("text_2");
}
2. Infinite loop before statements
#include <stdio.h>
int main()
{
int x = 5;
for (;;)
{
if (x == 5)
{
break;
printf("Hello World");
}
}
return 0;
}
3. Statements after continue statements
#include <stdio.h>
int main()
{
for (int i = 0; i < 10; i++)
{
continue;
printf("Hello World");
}
return 0;
}
4. False conditions in if statements
#include <stdio.h>
int main()
{
double X = 1.55;
if (X > 5)
{
X++;
}
return 0;
}
Task 2
Show examples of unreachable code based on https://pvs-studio.com/en/blog/terms/0090/
Convert examples to the C language