Major Project · Minor Project · Program Slicing · Projects · Technical Stuff

What is Program Slicing?

In computer programming, Program Slicing is the computation of the set of programs statements, the program slice, that may affect the values at some point of interest, referred to as a slicing criterion.

Slicing means finding all those statements that might directly or indirectly affect the values of variables in a set V

  • Depends on the program location
  • Mapping mental abstractions of programmers
  • Easing program maintenance tasks (debugging)
  • The criterion that defines the slicing problem is a pair C=(p,V) where p denotes program location
  • The criterion is the slicing criterion

Program slicing can be used in debugging to locate source of errors more easily. Other applications of slicing include software maintenance, optimization, program analysis, and information flow control.

Below is an example of Slicing

  • Source Code
int i;
int sum = 0;
int product = 1;
for(i = 1; i < N; ++i) {
  sum = sum + i;
  product = product * i;
}
write(sum);
write(product);
  • Sliced Code -criterion (write(sum),{sum})
int i;
int sum = 0;
 
for(i = 1; i < N; ++i) {
  sum = sum + i;
 
}
write(sum);

2 thoughts on “What is Program Slicing?

Leave a comment