Page 15 - Data Structures Interactive Book
P. 15

1.1.2  Control Structures


                       Control  structures  determine  the  flow  of  execution  in  a  program.  They  allow

               programmers  to  implement  decision-making  and  repetition.  The  if  and  else  statements

               enable  conditional  execution  based  on  logical  expressions,  while  the  switch  statement

               provides a cleaner way to handle multiple cases. Iteration structures such as for, while, and

               do-while  loops  allow  repeated  execution  of  code  blocks  until  a  condition  is  met.  These
               constructs  are  fundamental  for  building  programs  that  react  dynamically  to  input  and

               automate repetitive tasks.

                       •  Selection structures: if, else, and switch enable decision-making.
                       •  Iteration structures: for, while, and do-while loops repeat actions until conditions

                          are met.

                       Example:












                  1.2  Object-Oriented Programming


                       Object-Oriented  Programming  (OOP)  is  one  of  the  most  significant  features  that

               distinguishes C++ from C. OOP organizes software design around objects, which combine data
               and  behavior  into  a  single  unit.  This  paradigm  promotes  modularity,  reusability,  and

               scalability, making it easier to manage complex systems. The core principles of OOP in C++

               include encapsulation, inheritance, and polymorphism. Encapsulation ensures that data and
               methods are bundled together, inheritance allows classes to derive properties from other

               classes,  and  polymorphism  enables  functions  to  take  multiple  forms.  Together,  these

               principles provide a robust framework for designing flexible and maintainable software.


               1.2.1  Classes and Objects


                       A class in C++ is a blueprint that defines attributes (data members) and behaviors

               (member functions). Objects are instances of classes that represent real-world entities in a


                                                             15
   10   11   12   13   14   15   16   17   18   19   20