Slicing - Software Engineering Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report This article focuses on discussing Slicing in Software Engineering. What is Slicing?Slicing or program slicing is a technique used in software testing that takes a slice or a group of program statements in the program for testing particular test conditions or cases that may affect a value at a particular point of interest. It can also be used to debug to find the bugs more easily and quickly. Slicing techniques were originally defined by Mark Weiser and they were only static at that time. Afterward, Bogdan Korel and Janusz Laski introduced dynamic slicing, which can work for a particular execution of the program. Below is the C++ program to implement Slicing: C++// C++ program to implement slicing #include <iostream> using namespace std; int main() { int n = 12; int sum = 0; if (n > 10) sum = sum + n; else sum = sum - n; cout << "Hey"; } [tabbyending] OutputHeyThere are 2 types of Slicing: Types of SlicingStatic SlicingA static slice of a program contains all statements that may impact the value of a variable at any point for any arbitrary execution of the program.Static slices are generally larger.It considers every possible execution of the program.Below is the C++ program to implement static slicing: C++// C++ program to implement static // slicing #include <iostream> using namespace std; // Driver code int main() { int n = 12; int sum = 0; if (n > 10) sum = sum + n; else sum = sum - n; cout << sum; }[tabbyending] Output12Dynamic Slicing A dynamic slice of a program contains all the statements that actually impact the value of a variable at any point for a particular execution of the program.Dynamic slices are mostly smaller.Considers only a particular execution of the program.Below is the C++ program to implement dynamic slicing for the variable sum when n = 22: C++// C++ program to implement dynamic // slicing #include <iostream> using namespace std; // Driver code int main() { int n = 22; int sum = 0; if (n > 10) sum = sum + n; cout << sum; }[tabbyending] Output22 Explanation: As it can be observed in the above example the static slice takes all the possible execution (in this case it is 2) of the program which may affect the value of the variable sum. Whereas in the case of dynamic slicing, it considers only a particular execution (when n = 22) of the program which actually impacts the value of the variable sum. Hence, the dynamic slice is always smaller than a static slice. Comment More infoAdvertise with us Next Article Introduction to Software Engineering R raman_257 Follow Improve Article Tags : Software Engineering Similar Reads Introduction to Software Engineering Software is a program or set of programs containing instructions that provide the desired functionality. Engineering is the process of designing and building something that serves a particular purpose and finds a cost-effective solution to problems. Table of ContentWhat is Software Engineering?Key P 11 min read COCOMO Model-Software Engineering COCOMO-II is the revised version of the original Cocomo (Constructive Cost Model) and was developed at the University of Southern California. It is the model that allows one to estimate the cost, effort, and schedule when planning a new software development activity. Sub-Models of COCOMO ModelCOCOMO 2 min read Function Oriented Design - Software Engineering The design process for software systems often has two levels. At the first level, the focus is on deciding which modules are needed for the system based on SRS (Software Requirement Specification) and how the modules should be interconnected. Function Oriented Design is an approach to software desig 3 min read Functions Decomposition in Software Engineering The function decomposition is important in software engineering because it helps us to create more manageable modules. This decomposition of functions in chapter engineering also helps us to understand and design the software systems more easily. In this article, we are going to understand function 9 min read Component Based Software Engineering Component-Based Software Engineering (CBSE) is a process that focuses on the design and development of computer-based systems with the use of reusable software components. It not only identifies candidate components but also qualifies each component's interface, adapts components to remove architect 2 min read Classification of Software - Software Engineering Software Engineering is the process of developing a software product in a well-defined systematic approach software engineering is the process of analyzing user needs and then designing, constructing, and testing end-user applications that will satisfy these needs through the use of software program 8 min read Like