Object-Oriented Programming (OOP) is a programming paradigm that focuses on organizing and modeling software as a collection of objects. In OOP, objects are instances of classes, which serve as blueprints or templates for defining the structure and behavior of those objects. OOP is built on several key principles and concepts, which include:
Objects: Objects are the basic building blocks of an OOP system. They represent real-world entities, and they encapsulate both data (attributes or properties) and behavior (methods or functions) that operate on that data.
Classes: Classes are the templates or blueprints from which objects are created. They define the attributes and methods that objects of the class will possess. Classes enable the concept of abstraction, allowing you to create objects with common characteristics and behaviors.
Encapsulation: Encapsulation is the concept of bundling data (attributes) and methods (functions) that operate on that data into a single unit, i.e., a class. This unit is called an object. Encapsulation restricts access to the internal state of an object, providing data hiding and promoting information hiding, which helps manage complexity and reduces potential issues.
Inheritance: Inheritance is a mechanism that allows a class (a child or derived class) to inherit the attributes and methods of another class (a parent or base class). This promotes code reusability and the creation of specialized classes.
Polymorphism: Polymorphism allows objects of different classes to be treated as objects of a common base class. It enables the use of a single interface to represent a general class of actions. Polymorphism can take the form of method overriding (a subclass provides a specific implementation of a method defined in its superclass) or method overloading (multiple methods with the same name but different parameters).
Abstraction: Abstraction is the process of simplifying complex reality by modeling classes based on the essential properties and behaviors. It hides the unnecessary details while providing a clear and well-defined interface for interacting with objects.
Object-Oriented Programming is widely used in various programming languages like C++, Java, C#, Python, and more. It promotes code organization, modularity, and the modeling of real-world entities in a way that makes it easier to design, develop, and maintain software systems. OOP is particularly suited for large and complex projects where code readability, reusability, and maintainability are critical.
The document provides an overview of object-oriented programming concepts in C++. It discusses key OOP concepts like objects, classes, encapsulation, inheritance and polymorphism. It also covers procedural programming in C++ and compares it with OOP. Examples are provided to demonstrate creating classes, objects, functions, constructors and destructors. The document contains information on basic C++ programming concepts needed to understand and implement OOP principles in C++ programs.
This document provides an overview of the C++ programming language. It discusses key C++ concepts like classes, objects, functions, and data types. Some key points:
- C++ is an object-oriented language that is an extension of C with additional features like classes and inheritance.
- Classes allow programmers to combine data and functions to model real-world entities. Objects are instances of classes.
- The document defines common C++ terms like keywords, identifiers, constants, and operators. It also provides examples of basic programs.
- Functions are described as modular and reusable blocks of code. Parameter passing techniques like pass-by-value and pass-by-reference are covered.
- Other concepts covered include
C++ is computer programming language.It is very important computer programming language.C++ is easy to understand but it need a lot practice and hardworking.Classes and Objects are the most important topics in C++ and it is necessary to understand it.Similarly the use of Constructors is also very important to understand to learn C++These are descriptive and easy slides about Classes in C++.By studying these slides I strongly believe that you can clear your concepts.If you are in doubt and uncleared about Classes in C++ ,then you are at the right place.Read the whole slides and make your concepts clear.
The document outlines a lecture plan for object oriented programming. It covers topics like structures and classes, function overloading, constructors and destructors, operator overloading, inheritance, polymorphism, and file streams. It provides examples to explain concepts like structures, classes, access specifiers, friend functions, and operator overloading. The document also includes questions for students to practice these concepts.
This document discusses object-oriented programming concepts in C++ including constructors, destructors, polymorphism, and UML diagrams. It provides examples of default constructors, parameterized constructors, copy constructors, constructor overloading, method overloading, operator overloading, and sequence and collaboration diagrams. Constructors initialize objects, destructors destroy objects, and polymorphism allows the same message to have different implementations. UML interaction diagrams model dynamic system behavior through object interactions.
This document provides an overview of object-oriented programming (OOP) concepts in C++. It defines key OOP concepts like class, object, inheritance, encapsulation, abstraction, polymorphism, and overloading. It provides examples to illustrate class and object, inheritance with different types, encapsulation by hiding data, and function overloading. The document was prepared by a trainee as part of a mentoring program and provides contact information for the training organization.
This document provides an overview of an intermediate computer programming course at the University of Gondar in Ethiopia. The course code is CoEng2111 and it is taught by instructor Wondimu B. Topics that will be covered in the course include C++ basics, arrays, strings, functions, and recursion. The course materials are presented over several pages that define concepts, provide code examples, and explain key ideas like variables, data types, operators, and array implementation in C++.
The document provides an overview of object-oriented programming concepts in C++. It discusses key OOP concepts like objects, classes, encapsulation, inheritance and polymorphism. It also covers procedural programming in C++ and compares it with OOP. Examples are provided to demonstrate creating classes, objects, functions, constructors and destructors. The document contains information on basic C++ programming concepts needed to understand and implement OOP principles in C++ programs.
This document provides an overview of the C++ programming language. It discusses key C++ concepts like classes, objects, functions, and data types. Some key points:
- C++ is an object-oriented language that is an extension of C with additional features like classes and inheritance.
- Classes allow programmers to combine data and functions to model real-world entities. Objects are instances of classes.
- The document defines common C++ terms like keywords, identifiers, constants, and operators. It also provides examples of basic programs.
- Functions are described as modular and reusable blocks of code. Parameter passing techniques like pass-by-value and pass-by-reference are covered.
- Other concepts covered include
C++ is computer programming language.It is very important computer programming language.C++ is easy to understand but it need a lot practice and hardworking.Classes and Objects are the most important topics in C++ and it is necessary to understand it.Similarly the use of Constructors is also very important to understand to learn C++These are descriptive and easy slides about Classes in C++.By studying these slides I strongly believe that you can clear your concepts.If you are in doubt and uncleared about Classes in C++ ,then you are at the right place.Read the whole slides and make your concepts clear.
The document outlines a lecture plan for object oriented programming. It covers topics like structures and classes, function overloading, constructors and destructors, operator overloading, inheritance, polymorphism, and file streams. It provides examples to explain concepts like structures, classes, access specifiers, friend functions, and operator overloading. The document also includes questions for students to practice these concepts.
This document discusses object-oriented programming concepts in C++ including constructors, destructors, polymorphism, and UML diagrams. It provides examples of default constructors, parameterized constructors, copy constructors, constructor overloading, method overloading, operator overloading, and sequence and collaboration diagrams. Constructors initialize objects, destructors destroy objects, and polymorphism allows the same message to have different implementations. UML interaction diagrams model dynamic system behavior through object interactions.
This document provides an overview of object-oriented programming (OOP) concepts in C++. It defines key OOP concepts like class, object, inheritance, encapsulation, abstraction, polymorphism, and overloading. It provides examples to illustrate class and object, inheritance with different types, encapsulation by hiding data, and function overloading. The document was prepared by a trainee as part of a mentoring program and provides contact information for the training organization.
This document provides an overview of an intermediate computer programming course at the University of Gondar in Ethiopia. The course code is CoEng2111 and it is taught by instructor Wondimu B. Topics that will be covered in the course include C++ basics, arrays, strings, functions, and recursion. The course materials are presented over several pages that define concepts, provide code examples, and explain key ideas like variables, data types, operators, and array implementation in C++.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
Namespace defines a scope for identifiers used in a program. Reference variables provide an alias for previously defined variables, and their main purpose is passing arguments to functions. C++ defines new and delete operators for allocating and freeing memory. The main() cannot directly access private data members; they must use member functions. A private member function can only be called by another member function of its class. A static member function can be called using the class name as class-name::function-name.
data structure and c programing conceptskavitham66441
A structure allows grouping of different data types under a single name. It can be used to represent a record by defining members for each attribute. Structures support defining arrays of structures to group multiple records together. Unions share memory between members and only one member can be accessed at a time, while structures have independent memory for each member. Pointers store the address of a variable and allow dynamic memory allocation by changing which variable an address points to.
C# programs use namespaces and classes. A class defines methods and variables. C# supports inheritance, interfaces, structs, and enums. The main method runs code. Common data types include primitive types like int and reference types like string. C# can read input, perform math operations, and conditionally execute code using if/else statements. Methods can pass parameters by value or reference.
The document discusses C preprocessors and user-defined data types in C like structures and unions. It explains that the preprocessor is a program that processes code before compilation. Key preprocessor directives include #include, #define, #ifdef, and #line. Structures allow grouping of different data types while unions allocate space for the largest member. Typedefs create aliases for existing types. Enumerations define sets of named integer constants.
The document discusses function overloading in C++ and provides an example program to calculate the area of different shapes using function overloading. It then discusses constructors and destructors with examples and explains polymorphism with an example. Next, it discusses different types of inheritance in C++ and provides an example program to implement operator overloading for a distance class. It also discusses virtual functions with an example and access specifiers in classes. Finally, it provides examples to define a student class, implement quicksort using templates and overloading relational operators.
C# programs use the .cs file extension and consist of namespaces, classes, and methods. A basic C# program defines a Main method within a class, where code is written. Classes can inherit from other classes and implement interfaces. The document provides an overview of basic C# concepts like data types, strings, enums, structures, and passing parameters by value and reference. It also demonstrates how to get input, write output, and use common .NET classes.
The document discusses principles of writing clean code through perspectives from different authors. It emphasizes that clean code is readable, maintainable with minimal dependencies, well-tested, has meaningful names, focuses on doing one thing well with minimal lines of code per function. Comments should explain intent rather than make up for poor code quality. Function arguments, switch statements, and comments should be used judiciously.
The document discusses fundamentals of object-oriented programming. It defines objects as software bundles that model real-world objects using variables to represent states and methods to represent behaviors. Classes are blueprints that define common variables and methods for objects. Objects interact by sending messages to each other specifying a method and parameters. Object-oriented principles of abstraction, encapsulation, inheritance and polymorphism are covered.
Data Structure & Algorithm - Self Referentialbabuk110
The document discusses structures in C programming. It defines a structure as a collection of logically related data items of different datatypes grouped together under a single name. Some key points discussed include:
- Structures allow user-defined datatypes that can group different data types together.
- Structures are defined using the struct keyword followed by the structure name and members.
- Structure variables are declared to use the structure datatype. Arrays of structures can also be defined.
- Members of a structure can be accessed using the dot (.) operator or arrow (->) operator for pointers to structures.
The document provides examples of defining, declaring, and accessing structure variables and members.
The document discusses the Objective-C preprocessor and underlying C language features. It covers preprocessor directives like #define, #import, #include, and #undef. It also discusses arrays, structures, pointers, functions, and how Objective-C works with C at a low level. Blocks in Objective-C are described as being similar to functions but having some differences like needing to be declared in .m files instead of .h headers.
Structured Languages- Need and Characteristics of OOP, Data Types and Modifiers, Arrays, Classes, Objects, Pointers, References, Difference between Pointers and References, Inheritance, Constructors, Destructors, and Polymorphism.
OOP stands for Object-Oriented Programming. It involves creating objects that contain both data and methods. Classes act as templates for objects and define their attributes and behaviors. Some advantages of OOP include reusability, organization, and reduced repetition of code. Classes contain fields to store data and methods to perform actions on that data. Objects are instances of classes that inherit all fields and methods. Constructors initialize objects and can set initial field values. Arrays can store multiple objects. Dynamic arrays allow adding elements at runtime. Partial classes allow splitting a class definition across multiple files.
This document provides information on various .NET and C# concepts:
1. It begins with an example C# program that multiplies two numbers and prints the result, demonstrating basic program structure and comments.
2. It then covers identifiers, keywords, single-line and multi-line comments in C#, and the differences between value types and reference types.
3. The document concludes by discussing object-oriented programming concepts in C# like classes, constructors, destructors, methods, inheritance, polymorphism, abstraction, interfaces, and abstract classes.
Operator overloading allows operators like +, -, *, etc. to be used with user-defined types by defining specific method implementations. It enables operations on user-defined classes to behave similarly to built-in types. The document provides examples of overloading unary and binary operators in C# classes to change the sign of a number and add two calculator objects respectively. It also discusses the different operators that can and cannot be overloaded and how to define the operator overloading methods with the correct return types and parameters.
C++ is an object-oriented programming language that is an extension of C. It was developed in the early 1980s by Bjarne Stroustrup at Bell Labs. C++ supports concepts like inheritance, polymorphism, and encapsulation that make it suitable for large, complex programs. Inheritance allows classes to inherit properties from parent classes. Polymorphism is the ability to process objects of different types in the same way. Encapsulation combines data and functions that operate on that data within a single unit, hiding implementation details. File input/output in C++ can be handled through streams like ifstream for input and ofstream for output.
This document discusses object-oriented programming concepts in Objective-C such as classes, inheritance, polymorphism, and exceptions. It covers creating interface and implementation files, using properties and methods, inheritance hierarchies with subclasses, overriding methods, abstract classes, polymorphism through dynamic binding, and exceptions. Key topics include creating .h and .m files to define a class, using self to reference the current object, returning objects from methods, and extending classes through inheritance while allowing method overriding.
This document provides an introduction to Objective-C, including:
- Objective-C is a programming language used by Apple for iOS and Mac apps that is a superset of C and adds object-oriented capabilities.
- The language consists of objects, classes, methods, and messages that allow objects to communicate with each other.
- Keywords like @interface, @implementation, and @protocol are used to define classes, categories, and protocols.
- The document discusses features like properties, memory management, and differences between instance and class methods.
This document provides an overview and introduction to the C# programming language. It begins with setting up the environment needed to code in C#, which includes Visual Studio and a Windows PC. The document then discusses basic C# syntax like data types, variables, operators, and conditional statements. It also covers arrays, strings, and encapsulation. The goal is to provide beginners with an understanding of fundamental C# concepts to get started with the language.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
More Related Content
Similar to INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
Namespace defines a scope for identifiers used in a program. Reference variables provide an alias for previously defined variables, and their main purpose is passing arguments to functions. C++ defines new and delete operators for allocating and freeing memory. The main() cannot directly access private data members; they must use member functions. A private member function can only be called by another member function of its class. A static member function can be called using the class name as class-name::function-name.
data structure and c programing conceptskavitham66441
A structure allows grouping of different data types under a single name. It can be used to represent a record by defining members for each attribute. Structures support defining arrays of structures to group multiple records together. Unions share memory between members and only one member can be accessed at a time, while structures have independent memory for each member. Pointers store the address of a variable and allow dynamic memory allocation by changing which variable an address points to.
C# programs use namespaces and classes. A class defines methods and variables. C# supports inheritance, interfaces, structs, and enums. The main method runs code. Common data types include primitive types like int and reference types like string. C# can read input, perform math operations, and conditionally execute code using if/else statements. Methods can pass parameters by value or reference.
The document discusses C preprocessors and user-defined data types in C like structures and unions. It explains that the preprocessor is a program that processes code before compilation. Key preprocessor directives include #include, #define, #ifdef, and #line. Structures allow grouping of different data types while unions allocate space for the largest member. Typedefs create aliases for existing types. Enumerations define sets of named integer constants.
The document discusses function overloading in C++ and provides an example program to calculate the area of different shapes using function overloading. It then discusses constructors and destructors with examples and explains polymorphism with an example. Next, it discusses different types of inheritance in C++ and provides an example program to implement operator overloading for a distance class. It also discusses virtual functions with an example and access specifiers in classes. Finally, it provides examples to define a student class, implement quicksort using templates and overloading relational operators.
C# programs use the .cs file extension and consist of namespaces, classes, and methods. A basic C# program defines a Main method within a class, where code is written. Classes can inherit from other classes and implement interfaces. The document provides an overview of basic C# concepts like data types, strings, enums, structures, and passing parameters by value and reference. It also demonstrates how to get input, write output, and use common .NET classes.
The document discusses principles of writing clean code through perspectives from different authors. It emphasizes that clean code is readable, maintainable with minimal dependencies, well-tested, has meaningful names, focuses on doing one thing well with minimal lines of code per function. Comments should explain intent rather than make up for poor code quality. Function arguments, switch statements, and comments should be used judiciously.
The document discusses fundamentals of object-oriented programming. It defines objects as software bundles that model real-world objects using variables to represent states and methods to represent behaviors. Classes are blueprints that define common variables and methods for objects. Objects interact by sending messages to each other specifying a method and parameters. Object-oriented principles of abstraction, encapsulation, inheritance and polymorphism are covered.
Data Structure & Algorithm - Self Referentialbabuk110
The document discusses structures in C programming. It defines a structure as a collection of logically related data items of different datatypes grouped together under a single name. Some key points discussed include:
- Structures allow user-defined datatypes that can group different data types together.
- Structures are defined using the struct keyword followed by the structure name and members.
- Structure variables are declared to use the structure datatype. Arrays of structures can also be defined.
- Members of a structure can be accessed using the dot (.) operator or arrow (->) operator for pointers to structures.
The document provides examples of defining, declaring, and accessing structure variables and members.
The document discusses the Objective-C preprocessor and underlying C language features. It covers preprocessor directives like #define, #import, #include, and #undef. It also discusses arrays, structures, pointers, functions, and how Objective-C works with C at a low level. Blocks in Objective-C are described as being similar to functions but having some differences like needing to be declared in .m files instead of .h headers.
Structured Languages- Need and Characteristics of OOP, Data Types and Modifiers, Arrays, Classes, Objects, Pointers, References, Difference between Pointers and References, Inheritance, Constructors, Destructors, and Polymorphism.
OOP stands for Object-Oriented Programming. It involves creating objects that contain both data and methods. Classes act as templates for objects and define their attributes and behaviors. Some advantages of OOP include reusability, organization, and reduced repetition of code. Classes contain fields to store data and methods to perform actions on that data. Objects are instances of classes that inherit all fields and methods. Constructors initialize objects and can set initial field values. Arrays can store multiple objects. Dynamic arrays allow adding elements at runtime. Partial classes allow splitting a class definition across multiple files.
This document provides information on various .NET and C# concepts:
1. It begins with an example C# program that multiplies two numbers and prints the result, demonstrating basic program structure and comments.
2. It then covers identifiers, keywords, single-line and multi-line comments in C#, and the differences between value types and reference types.
3. The document concludes by discussing object-oriented programming concepts in C# like classes, constructors, destructors, methods, inheritance, polymorphism, abstraction, interfaces, and abstract classes.
Operator overloading allows operators like +, -, *, etc. to be used with user-defined types by defining specific method implementations. It enables operations on user-defined classes to behave similarly to built-in types. The document provides examples of overloading unary and binary operators in C# classes to change the sign of a number and add two calculator objects respectively. It also discusses the different operators that can and cannot be overloaded and how to define the operator overloading methods with the correct return types and parameters.
C++ is an object-oriented programming language that is an extension of C. It was developed in the early 1980s by Bjarne Stroustrup at Bell Labs. C++ supports concepts like inheritance, polymorphism, and encapsulation that make it suitable for large, complex programs. Inheritance allows classes to inherit properties from parent classes. Polymorphism is the ability to process objects of different types in the same way. Encapsulation combines data and functions that operate on that data within a single unit, hiding implementation details. File input/output in C++ can be handled through streams like ifstream for input and ofstream for output.
This document discusses object-oriented programming concepts in Objective-C such as classes, inheritance, polymorphism, and exceptions. It covers creating interface and implementation files, using properties and methods, inheritance hierarchies with subclasses, overriding methods, abstract classes, polymorphism through dynamic binding, and exceptions. Key topics include creating .h and .m files to define a class, using self to reference the current object, returning objects from methods, and extending classes through inheritance while allowing method overriding.
This document provides an introduction to Objective-C, including:
- Objective-C is a programming language used by Apple for iOS and Mac apps that is a superset of C and adds object-oriented capabilities.
- The language consists of objects, classes, methods, and messages that allow objects to communicate with each other.
- Keywords like @interface, @implementation, and @protocol are used to define classes, categories, and protocols.
- The document discusses features like properties, memory management, and differences between instance and class methods.
This document provides an overview and introduction to the C# programming language. It begins with setting up the environment needed to code in C#, which includes Visual Studio and a Windows PC. The document then discusses basic C# syntax like data types, variables, operators, and conditional statements. It also covers arrays, strings, and encapsulation. The goal is to provide beginners with an understanding of fundamental C# concepts to get started with the language.
Similar to INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx (20)
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Embedded machine learning-based road conditions and driving behavior monitoringIJECEIAES
Car accident rates have increased in recent years, resulting in losses in human lives, properties, and other financial costs. An embedded machine learning-based system is developed to address this critical issue. The system can monitor road conditions, detect driving patterns, and identify aggressive driving behaviors. The system is based on neural networks trained on a comprehensive dataset of driving events, driving styles, and road conditions. The system effectively detects potential risks and helps mitigate the frequency and impact of accidents. The primary goal is to ensure the safety of drivers and vehicles. Collecting data involved gathering information on three key road events: normal street and normal drive, speed bumps, circular yellow speed bumps, and three aggressive driving actions: sudden start, sudden stop, and sudden entry. The gathered data is processed and analyzed using a machine learning system designed for limited power and memory devices. The developed system resulted in 91.9% accuracy, 93.6% precision, and 92% recall. The achieved inference time on an Arduino Nano 33 BLE Sense with a 32-bit CPU running at 64 MHz is 34 ms and requires 2.6 kB peak RAM and 139.9 kB program flash memory, making it suitable for resource-constrained embedded systems.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELgerogepatton
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
1. INTRODUCTION TO
OBJECT ORIENTED PROGRAMMING
1. Principles of OOP
2. Applications and structure of C++ program
3. Different Data types, Variables
4. Different Operators, expressions, operator overloading,
5. control structures in C++.
Ms.S.DEEPA M.E.,(Ph.d.)
Assistant Professor (SL.G)
Computer Science and Engineering
KIT-Kalaignarkarunanidhi Institute Of Technology
2. C++ Data Types
int myNum = 5; // Integer (whole number)
float myFloatNum = 5.99; // Floating point number
double myDoubleNum = 9.98; // Floating point number
char myLetter = 'D'; // Character
bool myBoolean = true; // Boolean
string myText = "Hello"; // String
Data Type Size Description
boolean 1 byte Stores true or false values
char 1 byte Stores a single character/letter/number, or ASCII values
int 2 or 4 bytes Stores whole numbers, without decimals
float 4 bytes Stores fractional numbers, containing one or more decimals. Sufficient for
storing 6-7 decimal digits
double 8 bytes Stores fractional numbers, containing one or more decimals. Sufficient for
storing 15 decimal digits
3. Introduction to User-Defined Data Types in C++
• User Defined Data types in C++ are a type for
representing data. The data type will inform the
interpreter how the programmer will use the data.
• As the programming languages allow the user to create
their own data types according to their needs, the data
types defined by the users are known as user-defined
data types.
5. Structure
A structure is a collection of various types of related
information under one name. The declaration of structure forms a
template, and the variables of structures are known as members. All
the members of the structure are generally related. The keyword used
for the structure is “struct.”
Syntax:
struct { // Structure declaration
int myNum; // Member (int variable)
string myString; // Member (string variable)
} myStructure; // Structure variable
6. Example1:
// Create a structure variable called myStructure
struct {
int myNum;
string myString;
} myStructure;
// Assign values to members of myStructure
myStructure.myNum = 1;
myStructure.myString = "Hello World!";
// Print members of myStructure
cout << myStructure.myNum << "n";
cout << myStructure.myString << "n";
Output
1
Hello World!
7. One Structure in Multiple Variables
syntax
struct {
int myNum;
string myString;
} myStruct1, myStruct2, myStruct3;
// Multiple structure variables separated with commas
Output
BMW X5 1999
Ford Mustang 1969
8. #include <iostream>
#include <string>
using namespace std;
int main()
{
struct {
string brand;
string model;
int year;
} myCar1, myCar2; // We can add
variables by separating them with a
comma here
// Put data into the first structure
myCar1.brand = "BMW";
myCar1.model = "X5";
myCar1.year = 1999;
// Put data into the second structure
myCar2.brand = "Ford";
myCar2.model = "Mustang";
myCar2.year = 1969;
// Print the structure members
cout << myCar1.brand << " " <<
myCar1.model << " " <<
myCar1.year << "n";
cout << myCar2.brand << " " <<
myCar2.model << " " <<
myCar2.year << "n";
return 0;
}
9. • Named Structures
By giving a name to the structure, you can treat it as a data type. This means
that you can create variables with this structure anywhere in the program at
any
syntax
struct myDataType { // This structure is named "myDataType"
int myNum;
string myString;
};
myDataType myVar;
10. #include <iostream>
#include <string>
using namespace std;
// Declare a structure named "car"
struct car {
string brand;
string model;
int year; };
int main() {
// Create a car structure and store it
in myCar1;
car myCar1;
myCar1.brand = "BMW";
myCar1.model = "X5";
myCar1.year = 1999;
// Create another car structure and
store it in myCar2;
car myCar2;
myCar2.brand = "Ford";
myCar2.model = "Mustang";
myCar2.year = 1969;
11. Union
• Union is a user-defined datatype. All the members of union share
same memory location. Size of union is decided by the size of largest
member of union. If you want to use same memory location for two
or more members, union is the best for that.
• Unions are similar to structures. Union variables are created in same
manner as structure variables. The keyword “union” is used to
define unions in C language.
Syntax
union union_name {
member definition;
} union_variables;
12. Class
• A class is a user-defined data type that we can use in our program, and it
works as an object constructor, or a "blueprint" for creating objects.
• Everything in C++ is associated with classes and objects, along with its
attributes and methods. For example: in real life, a car is an object. The car
has attributes, such as weight and color, and methods, such as drive and
brake.
• Syntax
class MyClass { // The class
public: // Access specifier
int myNum; // Attribute (int variable)
string myString; // Attribute (string variable)
};
13. #include <iostream>
#include <string>
using namespace std;
class MyClass { // The class
public: // Access specifier
int myNum; // Attribute (int variable)
string myString; // Attribute (string variable)
};
int main() {
MyClass myObj; // Create an object of MyClass
// Access attributes and set values
myObj.myNum = 15;
myObj.myString = "Some text";
// Print values
cout << myObj.myNum << "n";
cout << myObj.myString;
return 0;
}
14. Access Specifiers
class MyClass { // The class
public: // Access specifier
// class members goes here
};
• The public keyword is an access specifier. Access specifiers
define how the members (attributes and methods) of a class
can be accessed.
In C++, there are three access specifiers:
•public - members are accessible from outside the class
•protected - members cannot be accessed from outside the
class, however, they can be accessed in inherited classes.
•private - members cannot be accessed (or viewed) from
outside the class
15. Example
#include <iostream>
using namespace std;
class MyClass {
public: // Public access specifier
int x; // Public attribute
private: // Private access specifier
int y; // Private attribute
};
int main() {
MyClass myObj;
myObj.x = 25; // Allowed (x is public)
myObj.y = 50; // Not allowed (y is
private)
return 0;
}
Output
In function 'int main()':
Line 8: error: 'int MyClass::y' is private
Line 14: error: within this context
16. • An enum is a special type that represents a group of constants
(unchangeable values)
syntax
enum Level {
LOW,
MEDIUM,
HIGH
};
To create an enum, use the enum keyword, followed by the
name of the enum, and separate the enum items with a
comma:
• Note that the last item does not need a comma.
• It is not required to use uppercase, but often considered as good practice.
• Enum is short for "enumerations", which means "specifically listed".
17. • To access the enum, you must create a variable of it.
• Inside the main() method, specify the enum keyword,
followed by the name of the enum (Level) and then the
name of the enum variable (myVar in this example):
By default, the first item (LOW) has the value 0, the second
(MEDIUM) has the value 1, etc.
If you now try to print myVar, it will output 1, which
represents MEDIUM:
18. Example
enum Level {
LOW,
MEDIUM,
HIGH
};
int main() {
// Create an enum variable and
assign a value to it
enum Level myVar = MEDIUM;
// Print the enum variable
printf("%d", myVar);
return 0;
}
Output
1
19. Change Values
• As you know, the first item of an enum has the value 0. The second has the
value 1, and so on.
• To make more sense of the values, you can easily change them:
enum Level {
LOW = 25,
MEDIUM = 50,
HIGH = 75
};
20. Example
enum Level {
LOW = 25,
MEDIUM = 50,
HIGH = 75
};
int main() {
enum Level myVar = MEDIUM;
printf("%d", myVar);
return 0;
}
Output
50
21.
22. C++ Storage Classes are used to describe the characteristics of a
variable/function. It determines the lifetime, visibility, default value, and
storage location which helps us to trace the existence of a particular variable
during the runtime of a program. Storage class specifiers are used to specify
the storage class for a variable.
Syntax
• storage_class var_data_type var_name;
C++ uses 4 storage classes, which are as follows:
• auto Storage Class
• register Storage Class
• extern Storage Class
• static Storage Class
23.
24.
25. Derived Data Types
The data-types that are derived from the primitive or built-in datatypes are
referred to as Derived Data Types. These can be of four types namely:
• Function
• Array
• Pointers
• References
26. C++ Functions
• A function is a block of code which only runs when it is called.
• You can pass data, known as parameters, into a function.
• Functions are used to perform certain actions, and they are important for
reusing code: Define the code once, and use it many times.
• C++ provides some pre-defined functions, such as main(),
which is used to execute code.
• But you can also create your own functions to perform certain actions.
• To create (often referred to as declare) a function, specify the name of the
function, followed by parentheses ():
27. Syntax
void myFunction() {
// code to be executed
}
Example
#include <iostream>
using namespace std;
void myFunction() {
cout << "I just got executed!";
}
int main() {
myFunction();
return 0;
}
Output
I just got executed!
28. #include <iostream>
usingnamespacestd;
// max here is a function derived type
intmax(intx, inty)
{
if(x > y)
returnx;
else
returny;
}
// main is the default function derived
type
intmain()
{
inta = 10, b = 20;
// Calling above function to
// find max of 'a' and 'b'
intm = max(a, b);
cout << "m is "<< m;
return0;
}
Output
m is 20
29. Array
An array is a collection of items stored at continuous memory locations. The
idea of array is to represent many instances in one variable.
Syntax:
DataType ArrayName[size_of_array];
30. C++ Arrays
• Arrays are used to store multiple values in a single variable, instead of
declaring separate variables for each value.
• To declare an array, define the variable type, specify the name of the array
followed by square brackets and specify the number of elements it should
store:
string cars[4];
string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
example
string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
cout << cars[0];
Output
Volvo
32. Pointers
Pointers are symbolic representation of addresses. They enable
programs to simulate call-by-reference as well as to create and
manipulate dynamic data structures. It’s general declaration in C/C++
has the format:
Syntax:
datatype *var_name;
Example:
int *ptr;
ptr points to an address which holds int data
33. #include <iostream>
using namespace std;
void geeks()
{
int var = 20;
// Pointers Derived Type
// declare pointer variable
int* ptr;
// note that data type of ptr
// and var must be same
ptr = &var;
// assign the address of a variable
// to a pointer
cout << "Value at ptr = "
<< ptr << "n";
cout << "Value at var = "
<< var << "n";
cout << "Value at *ptr = "
<< *ptr << "n";
}
// Driver program
int main()
{
geeks();
}
Output:
Value at ptr = 0x7ffc10d7fd5c
Value at var = 20
Value at *ptr = 20
34. Reference
• When a variable is declared as reference, it becomes an alternative name for
an existing variable. A variable can be declared as reference by putting ‘&’ in
the declaration
35. #include <iostream>
usingnamespacestd;
intmain()
{
intx = 10;
// Reference Derived Type
// ref is a reference to x.
int& ref = x;
// Value of x is now changed to 20
ref = 20;
cout << "x = "<< x << endl;
// Value of x is now changed to 30
x = 30;
cout << "ref = "<< ref << endl;
return0;
}
Output:
x = 20
ref = 30
36. C++ Variables
Variables are containers for storing data values.
In C++, there are different types of variables (defined with different
keywords), for example:
•int - stores integers (whole numbers), without decimals, such as 123 or -
123
•double - stores floating point numbers, with decimals, such as 19.99 or -
19.99
•char - stores single characters, such as 'a' or 'B'. Char values are surrounded
by single quotes
•string - stores text, such as "Hello World". String values are surrounded by
double quotes
•bool - stores values with two states: true or false
37. Declaring (Creating) Variables
syntax
type variableName = value;
Example
#include <iostream>
using namespace std;
int main() {
int myNum = 15;
cout << myNum;
return 0;
}
Output
15
38. Rules For Declaring Variable
• The name of the variable contains letters, digits, and underscores.
• The name of the variable is case sensitive (ex Arr and arr both are different
variables).
• The name of the variable does not contain any whitespace and special
characters (ex #,$,%,*, etc).
• All the variable names must begin with a letter of the alphabet or an
underscore(_).
• We cannot used C++ keyword(ex float,double,class)as a variable name.
Valid variable names:
int x; //can be letters
int _yz; //can be underscores
int z40;//can be letters
39.
40. Dynamic Initialization
• In this method, the variable is assigned a value at the run-time.
• The value is either assigned by the function in the program or by the user at
the time of running the program.
• The value of these variables can be altered every time the program runs.
int main() {
float p,r,t;
cout<<"principle amount, time and rate"<<endl;
cout<<"2000 7.5 2"<<endl;
simple_interest s1(2000,7.5,2);//dynamic initialization
s1.display();
return 1;
}
41. C++ operators
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Bitwise operators
Insertion operator <<
Extraction operator >>
Scope resolution operator ::
Pointer to member declarator ::*
declare pointer to member of a class
Pointer to member operator ->*
to access a member using a pointer to
the object and a pointer to that member
Pointer to member operator .*
To access a member using object name
and a pointer to that member
Memory release operator delete
Line feed operator endl
Memory allocation operator new
Field width operator setw
42. Dereference Operator
Dereferencing is the method where we are using a pointer to
access the element whose address is being stored. We use the
* operator to get the value of the variable from its address.
Example:
int a;
// Referencing
int *ptr=&a;
// Dereferencing
int b=*ptr;
43. #include <bits/stdc++.h>
using namespace std;
int main()
{
int a = 10, b = 20;
int* pt;
pt = &a;
cout << "The address where a is stored is: " << pt
<< endl;
cout << "The value stored at the address by "
"dereferencing the pointer is: "
<< *pt << endl;
}
44. Output
The address where a is stored is: 0x7ffdcae26a0c
The value stored at the address by dereferencing the
pointer is: 10
45. C++ Manipulator setw
• C++ manipulator setw function stands for set width. This manipulator is used
to specify the minimum number of character positions on the output field a
variable will consume.
• This manipulator is declared in header file <iomanip>.
Syntax
/*unspecified*/ setw (int n);
• n: number of characters to be used as filed width.
46. #include <iostream>
#include <iomanip>
using namespace std;
int main (void)
{
int a,b;
a = 200;
b = 300;
cout << setw (5) << a << setw (5) << b
<< endl;
cout << setw (6) << a << setw (6) << b
<< endl;
cout << setw (7) << a << setw (7) << b
<< endl;
cout << setw (8) << a << setw (8) << b
<< endl;
return 0;
}
Output
47. • If we assume the values of the variables as
2597
14
175
• respectively m=2597; n=14; p=175
• It was want to print all nos in right justified way use setw which specify a
common field width for all the nos.
48. Scope resolution operator in C++
#include <iostream>
using namespace std;
class A {
public:
// Only declaration
void fun();
};
// Definition outside class using ::
void A::fun() { cout << "fun() called"; }
int main()
{
A a;
a.fun();
return 0;
}
Output
fun() called
49. Memory management is a process of managing computer memory, assigning
the memory space to the programs to improve the overall system
performance.
A new operator is used to create the object while a delete operator is used to
delete the object.
syntax
pointer_variable = new data-type
int *p;
p = new int;
In the above example, 'p' is a pointer of type int.
50. float *q;
q = new float;
'q' is a pointer of type float.
In the above case, the declaration of pointers and their assignments are done
separately. We can also combine these two statements as follows:
int *p = new int;
float *q = new float;
We can assign the value to the newly created object by simply using the
assignment operator.
*p = 45;
*q = 9.8;
We can also assign the values by using new operator which can be done as
follows:
pointer_variable = new data-type(value);
int *p = new int(45);
float *p = new float(9.8);
When memory is no longer required, then it needs to be
deallocated so that the memory can be used for another
purpose. This can be achieved by using the delete
operator
51. When memory is no longer required, then it needs to be deallocated so
that the memory can be used for another purpose. This can be achieved
by using the delete operator
delete pointer_variable;
Example
delete p;
delete q;
52. CONTROL STRUCTURES:
The if statement:
The if statement is implemented in
two forms:
1. simple if statement
2. if… else statement
Simple if statement:
if (condition)
{
Action;
}
If.. else statement
If (condition)
{
Statment1
}
Else
{
Statement2
}
53. Less than: a < b
Less than or equal to: a <= b
Greater than: a > b
Greater than or equal to: a >= b
Equal to a == b
Not Equal to: a != b
54. C++ has the following conditional statements:
•Use if to specify a block of code to be executed, if a
specified condition is true
•Use else to specify a block of code to be executed, if the
same condition is false
•Use else if to specify a new condition to test, if the first
condition is false
•Use switch to specify many alternative blocks of code to
be executed
55. syntax
if (condition)
{
// block of code to be executed
if the condition is true
}
example
#include <iostream>
using namespace std;
int main() {
if (20 > 18)
{
cout << "20 is greater than 18";
}
return 0;
}
Output
20 is greater than 18
56. syntax
if (condition) {
// block of code to be executed if the
condition is true
}
else {
// block of code to be executed if the
condition is false
}
Example
#include <iostream>
using namespace std;
int main() {
int time = 20;
if (time < 18) {
cout << "Good day.";
} else {
cout << "Good evening.";
}
return 0;
}
Output
Good evening.
57. Syntax
if (condition1) {
// block of code to be executed if
condition1 is true
}
else if (condition2) {
// block of code to be executed if the
condition1 is false and condition2 is true
}
else {
// block of code to be executed if the
condition1 is false and condition2 is false
}
example
#include <iostream>
using namespace std;
int main()
{
int time = 22;
if (time < 10)
{
cout << "Good morning.";
}
else if (time < 20)
{
cout << "Good day.";
}
else {
cout << "Good evening.";
}
return 0;
}
58. The switch statement
This is a multiple-branching
statement where, based on
a condition, the control is
transferred to one of the
many possible points;
syntax
Switch(expr)
{
case 1:
action1;
break;
case 2:
action2;
break;
.. ..
default:
message
}
59. switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
This is how it works:
•The switch expression is
evaluated once
•The value of the expression
is compared with the values
of each case
•If there is a match, the
associated block of code is
executed
•The break and default keyw
ords are optional, and will be
described later in this chapter
60. Example
#include <iostream>
using namespace std;
int main()
{
int day = 4;
switch (day) {
case 1:
cout << "Monday";
break;
case 2:
cout << "Tuesday";
break;
case 3:
cout << "Wednesday";
break;
case 4:
cout << "Thursday";
break;
case 5:
cout << "Friday";
break;
case 6:
cout << "Saturday";
break;
case 7:
cout << "Sunday";
break;
}
return 0;
}
61. Example using default
#include <iostream>
using namespace std;
int main()
{
int day = 4;
switch (day) {
case 6:
cout << "Today is Saturday";
break;
case 7:
cout << "Today is Sunday";
break;
default:
cout << "Looking forward to the
Weekend";
}
return 0;
}
Output
Looking forward to the Weekend
63. Syntax
while (condition) {
// code block to be executed
}
Example
#include <iostream>
using namespace std;
int main() {
int i = 0;
while (i < 5) {
cout << i << "n";
i++;
}
return 0;
}
Output
0
1
2
3
4
64. Syntax
do {
// code block to be executed
}
while (condition);
Example
#include <iostream>
using namespace std;
int main() {
int i = 0;
do {
cout << i << "n";
i++;
}
while (i < 5);
return 0;
}
output
0
1
2
3
4
65. For loop
When you know exactly how many times you want to loop
through a block of code, use the for loop instead of
a while loop:
syntax
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
• Statement 1 is executed (one time) before the execution of the code block.
• Statement 2 defines the condition for executing the code block.
• Statement 3 is executed (every time) after the code block has been
executed.
68. #include <iostream>
using namespace std;
int main() {
// Outer loop
for (int i = 1; i <= 2; ++i) {
cout << "Outer: " << i << "n"; //
Executes 2 times
// Inner loop
for (int j = 1; j <= 3; ++j) {
cout << " Inner: " << j << "n"; //
Executes 6 times (2 * 3)
}
}
return 0;
}
Output
Outer: 1
Inner: 1
Inner: 2
Inner: 3
Outer: 2
Inner: 1
Inner: 2
Inner: 3
69. Operator overloading
Operator overloading is a type of polymorphism in which a single operator is
overloaded to give a user-defined meaning. Operator overloading provides a
flexible option for creating new definitions of C++ operators.
In C++, we can make operators work for user-defined classes.
This means C++ has the ability to provide the operators with a special meaning
for a data type, this ability is known as operator overloading.
For example, we can overload an operator ‘+’ in a class like String so that we
can concatenate two strings by just using +.
Other example classes where arithmetic operators may be overloaded are
Complex Numbers, Fractional Numbers, Big integers, etc.
71. Expression: An expression is a combination of operators, constants and
variables. An expression may consist of one or more operands, and zero
or more operators to produce a value.
72. •Constant expressions: Constant Expressions consists of only constant
values. A constant value is one that doesn’t change.
Examples:
5, 10 + 5 / 6.0, ‘x’
•Integral expressions: Integral Expressions are those which produce integer
results after implementing all the automatic and explicit type conversions.
Examples:x, x * y, x + int( 5.0)
where x and y are integer variables.
•Floating expressions: Float Expressions are which produce floating point
results after implementing all the automatic and explicit type conversions.
Examples:x + y, 10.75
where x and y are floating point variables.
73. Relational expressions:
Relational Expressions yield results of type bool which takes a value
true or false. When arithmetic expressions are used on either side of a
relational operator, they will be evaluated first and then the results
compared. Relational expressions are also known as Boolean
expressions.
Examples:x <= y, x + y > 2
Logical expressions:
Logical Expressions combine two or more relational expressions and
produces bool type results.
Examples: x > y && x == 10, x == 10 || y == 5
74. Pointer expressions:
Pointer Expressions produce address values.
Examples:
&x, ptr, ptr++
where x is a variable and ptr is a pointer.
Bitwise expressions:
Bitwise Expressions are used to manipulate data at bit level. They are
basically used for testing or shifting bits.
Examples:
x << 3
shifts three bit position to left
y >> 1
shifts one bit position to right.
Shift operators are often used for multiplication and division by powers
of two.