object oriented programming with c++, Exams of Object Oriented Programming

It is very useful to learn in few seconds .

Typology: Exams

2017/2018

Uploaded on 10/21/2018

music-world-1
music-world-1 🇮🇳

4 documents

1 / 63

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
tOBJECT ORIENTED PROGRAMMING USING C++
1.1 The Evolution of C++:
Computer languages have come a long way since the 1940’s. Back then, scientists punched
instructions in to mammoth, room-sized computer systems. These instructions were long series of zeroes
and ones. These machine language instructions are called the first generation of computer languages.
The 1950’s saw the emergence of the second generation computer languages-assembly language-easier
to write than machine language but still extremely complicated for a lay person. However, the computer
could still understand only machine language. Therefore, the assembler software was developed to
translate the code written in assembly language into machine language.
In 1967, Martin Richard developed a language called BPCL for writing operating systems. An
operating system is a set of programs that manages the resources of a computer and its interactions with
users.
The era of the third generation of computer languages had arrived. In 1970’s Ken Thompson
modified BPCL to create a new language called B. working for Bell Laboratories, Thompson teamed up
with Dennis Ritchie and wrote an early version of the Unix operating system for a DEC PDP-7 computer.
Dennis Ritchie was working on a project to further develop the Unix operating system. He wanted a
low-language, like the assembly language, the could control hardware efficiently. At the same time, he
wanted the language to provide the features of a high level language, that is, it should be able to run on
different types of hardware. B had performance drawbacks, so in 1972, he rewrote B and called in C.
Therefore, C is categorized as both a second and third generation language. Thompson and Ritchie
rewrote the Unix operating system in C. In the years that followed, C was widely accepted and used over
different hardware platforms. In 1989, the American National Standards Institute(ANSI), along with the
International Standards Organization (ISO), approved a machine independent and standard version of C.
In the early 1980’s , Bjarne Stroustrup working for Bell Labs developed the C++ language. In his
own words , “ C++ was designed primal so that my friends an I would not have to program in assembly,
C, or various modern high-level languages. Its main purpose was to make writing food programs easier
and more pleasant for the individual programmer”. (Bjarne Stroustup The C++ Programming Language,
Third Edition. Reading, MA: Addition Wesley Publishing Company 1997). C++ was originally known as ‘C
with classes’ as two languages contributed to its design. C which provided low-level features, and
simula67, which provided the class concept.
The C++ language is a superset of C. Like the C language, C++ is compact and can be used for
system programming. It can use existing C software libraries. (Libraries are collections of programs that you
can reuse in your program.) C++ has object-oriented programming (OOP) capabilities similar to an earlier
computer language called Simula67. C++ is called a hybrid language because it can be used both as a
procedural language like C and as an object-oriented language like Simula67, other object-oriented
languages include Smalltalk and Ada.
In 1990’s, the ANSI/ISO committee began working on a standard version of the C++ language. By
June 1998,the committee had approved the Final Draft International Standard for C++. It was released in
the form of a document. It extended the language to include exceptions, templates, and the Standard
Template Library ( STL).
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f

Partial preview of the text

Download object oriented programming with c++ and more Exams Object Oriented Programming in PDF only on Docsity!

tOBJECT ORIENTED PROGRAMMING USING C++

1.1 The Evolution of C++:

Computer languages have come a long way since the 1940’s. Back then, scientists punched instructions in to mammoth, room-sized computer systems. These instructions were long series of zeroes and ones. These machine language instructions are called the first generation of computer languages. The 1950’s saw the emergence of the second generation computer languages- assembly language- easier to write than machine language but still extremely complicated for a lay person. However, the computer could still understand only machine language. Therefore, the assembler software was developed to translate the code written in assembly language into machine language. In 1967, Martin Richard developed a language called BPCL for writing operating systems. An operating system is a set of programs that manages the resources of a computer and its interactions with users. The era of the third generation of computer languages had arrived. In 1970’s Ken Thompson modified BPCL to create a new language called B. working for Bell Laboratories, Thompson teamed up with Dennis Ritchie and wrote an early version of the Unix operating system for a DEC PDP-7 computer. Dennis Ritchie was working on a project to further develop the Unix operating system. He wanted a low-language, like the assembly language, the could control hardware efficiently. At the same time, he wanted the language to provide the features of a high level language, that is, it should be able to run on different types of hardware. B had performance drawbacks, so in 1972, he rewrote B and called in C. Therefore, C is categorized as both a second and third generation language. Thompson and Ritchie rewrote the Unix operating system in C. In the years that followed, C was widely accepted and used over different hardware platforms. In 1989, the American National Standards Institute( ANSI), along with the International Standards Organization (ISO), approved a machine independent and standard version of C. In the early 1980’s , Bjarne Stroustrup working for Bell Labs developed the C++ language. In his own words , “ C++ was designed primal so that my friends an I would not have to program in assembly, C, or various modern high-level languages. Its main purpose was to make writing food programs easier and more pleasant for the individual programmer”. (Bjarne Stroustup The C++ Programming Language, Third Edition. Reading, MA: Addition Wesley Publishing Company 1997). C++ was originally known as ‘C with classes’ as two languages contributed to its design. C which provided low-level features, and simula67, which provided the class concept. The C++ language is a superset of C. Like the C language, C++ is compact and can be used for system programming. It can use existing C software libraries. (Libraries are collections of programs that you can reuse in your program.) C++ has object-oriented programming (OOP) capabilities similar to an earlier computer language called Simula67. C++ is called a hybrid language because it can be used both as a procedural language like C and as an object-oriented language like Simula67, other object-oriented languages include Smalltalk and Ada. In 1990’s, the ANSI/ISO committee began working on a standard version of the C++ language. By June 1998,the committee had approved the Final Draft International Standard for C++. It was released in the form of a document. It extended the language to include exceptions, templates, and the Standard Template Library ( STL).

Object oriented programming

Software Evolution: The software evolution has had distinct phases or “layers” of growth. These layers were built up one by one over the last five decades as shown in figure. Each layer representing an improvement over the previous one. Fig. Layers of computer software Object-Oriented Programming (OOP) is an approach program organization and development that attributes to eliminate some of pitfalls of conventional programming methods by incorporating the best of structured programming features with several powerful new concepts. 1.2 Procedure – Oriented Programming: The high level languages such as COBOL, FORTRAN and C are commonly known as procedure- oriented programming (POP). In the procedure-oriented approach, the problem is viewed as a sequence of things and a number functions are written to accomplish these tasks. The primary focus is on functions. Procedural Programming Model : Each problem is divided into smaller problems and solved using specified modules that act on data. Fig – Structure of procedural-oriented programs

Procedure-oriented

Assembly language

Machine language

Main Program Function - (^1) Function - 2 Function - 4 Function - 3 Function - 5 Function - 6 Function - 7 Function - 8

The data of an object can be accessed only by the functions associated with the object. However, functions of one object can access the functions of other objects. Some of the striking features of object-oriented programming are:  Emphasis is on data rather than procedurePrograms are divided into what are known as objectData structures are designed such that they characterize the object.Functions that operate on the data of on object are tied together in the data structure.Data is hidden and cannot be accessed by external functions.New data and functions can be easily added whenever necessary.Follows bottom-up approach in program design. “Object-oriented programming as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as template for creating copies of such modules on demand”. Memory partitions are independent; the objects can be used in a variety of different programs without modifications. Object oriented programming model: It perceived the entire software system as a collections of objects which contain attributes and behaviors. BASICS CONCEPTS OF OBJECT – ORIENTED PROGRAMMING Some of the concepts used extensively in object-oriented programming. These include:  Objects  Classes  Data abstraction and encapsulation  Inheritance  Polymorphism  Dynamic binding  Message passing Object:Object is a triangle of entity that may be exhibiting some well-defined behavior. (Or) Object is an instance of Class (or) Everything is an object Objects are the basic run-time entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item the program has to handle. They may be represents user- defined data such as vectors, time and lists. When a program executed, the object interact by sending messages to one another. Each object contain data, and code to manipulate the data. Fig shows two notations that are popularly used in object- oriented analysis and design. Fig – Two ways of representing an object Classes:Class is a set of attributes and behavior shared by similar objects (or) in simple way collection of objects of similar type is called a Class. The entire set of data and code of an object can be made a user-defined data type with the help of a class. Objects are variable of the type class. Once a class has been defined, we can create any number of objects belonging to that class.

Object : STUDENT

DATA

Name

Date-of-Birth

Marks

FUNCTIONS

STUDENT

Total Average Display

If fruit has been defined as a class , then the statement.

fruit apple;

will create an object apple belonging to the class fruit. Data Abstraction and Encapsulation:Abstraction focuses on the essential characteristics of objects  Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and functions to operate on these attributes.  Since the classes use the concept of data abstraction, they are known as Abstract Data Types (ADT).  The attributes are sometimes called data members because they hold information. The functions that operate on these data are sometimes called methods or member functions.  Encapsulation: The wrapping up of data and function into a single unit (called class) is known as encapsulation****. The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.  This instruction of the data from direct access by the program is called data hiding or information hiding. Inheritance:Inheritance is the process by which object of one class acquire the properties of objects of another class. Create a new class derived from the old class.  It supports the concept of hierarchical classification. For example, the bird ‘robin’ is a part of the class ‘flying bird’ which is again a part of the class ‘bird’. The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived as illustrated in fig. Fig- property inheritance  In OOP, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it.  This is possible by deriving new class from the existing one. The new class will have the combined features of both the class. Bird Attribute Features Lay eggs Robin Attribute ………… ………… Flying Bird Attribute ………… ………… Swallow Attribute ………… ………… Penguin Attribute ………… ………… Kiwi Attribute ………… ………… Non-Flying Bird Attribute …………

Message passing involves specifying the name of the object, the name of the function (message) and the information to be sent. Example: Employee.salary (name); Object information Message Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive. Benefits of OOPs: OOP offers several benefits to both the program designer and user.  Through inheritance, we can eliminate redundant code and extend the use of existing classes.The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code on other parts of the program.It is possible to have multiple instances of on object to co-exist without any interference.It is possible to map objects in the problem domain to those objects in the program.It is easy to partition the work in a project based on objects.Object-oriented systems can be easily upgraded from small to large systems.Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler.Software complexity can be easily managed. Applications of OOP: Applications of OOP are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as windows. Windows are developed using OOP techniques. OOP is simplifying the complex problem. The other areas for application of OOP includes:  Real-time systemsSimulation and modelingObject-oriented databasesHypertext, hypermedia and expertextAI and expert systemsNeural networks and parallel programmingDecision support and office automation systemsCIM/CAM/CAD systems. Object-Oriented Languages: Object-oriented programming is not the right of any particular language. Like structured programming, OOP concepts can be implemented using languages such as C and Pascal. A language that is specially designed to support the OOP concepts makes it easier to implement them. The languages should support several of the OOP concepts to claim that they are object-oriented. Depending upon the features they support, they can be classified into the following two categories:  Object-based programming Languages  Object-oriented programming Languages.  Object-based programming is the style of programming that primarily supports encapsulation and object identity. Major features that are required for object-base programming are:  Data encapsulation  Data hiding and access mechanisms  Automatic initialization and clear-up of objects  Operator overloading

Languages that support programming with objects are said to be object-based programming languages. They do not support inheritance and dynamic binding. Ada is a typical object-based programming language.  Object-oriented programming incorporates all of object-based programming features along with two additional features, namely, inheritance and dynamic binding. It’s simply Object-based features + inheritance + dynamic binding. Languages that support these features include C++ , Smalltalk and object Pascal and java. There are a large number of object-based and object-oriented programming languages. C++ STREAMS A stream is a sequence of bytes. The source stream that provides data to the program is called the input stream and the destination stream that receives output from the program is called the output stream. A program extracts the bytes from and input stream and inserts bytes into an output stream. C++ STREAM CLASSES The C++ I/O system contains a hierarchy of classes that are used to define various streams to deal with both the console and disk files. These classes are called stream classes. Fig. Stream classes for console I/O operations Class name Contents ios : Contains basic facilities that are used by all other input and output classes istream : Declares input functions. Inherits the properties of ios ostream : Declares output functions. Inherits the properties of ios iostream : Contains all the input and output functions. Inherits ios, istream and ostream classes. streambuf : Provides an interface to physical devices through buffers. Input Device Output Device Program Input Stream Output Stream Extraction from input stream Insertion into output stream Fig. Data Streams pointer istream get( ) tellg( ) read( ) overload>> ios streambuf ostream put( ) tellp( ) write( ) overload<< istream_with assign iostream iostream_with assign ostream_with assign input output

fill( ) : Used to specify a character that is used to fill the unused portion of a field. *Syntax : cout.fill( arg ); Example : int a = 750 ; cout.width( 5 ); cout.fill(‘’); cout< Manipulators and their meanings setw () manipulator:-  Takes integer type of variable as its parameter. The parameter specifies the width of the column. Example: 1. cout<< 123<

UNIT - II

INTRODUCTION TO C++

C++ is an object-oriented programming language. Initially named ‘C with classes’, C++ was developed by Bjarne Stroustrup at AT& T Bell Laboratories in Murray Hill, New Jersey, USA, in the early eighties. In 1983, the name(“C with classes”) was changed to C++. The idea of C++ comes from the C increment operator ++, thereby suggesting that C++ is an incremented version of C. C++ is a superset of C. The three most important facilities that C++ adds on to C are classes, inheritance, function overloading, and operator overloading. These features enable us to create abstract data types, inherit properties from existing data types and support polymorphism, thus making C++ a truly object- oriented language. The addition of new features has transformed C from a language that to one that provides bottom-up, object-oriented design. Applications of C++: C++ is a versatile language for handling very large programs. It is suitable for virtually any programming task including development of editors, compilers, databases, communication systems and any complex real-life application systems.  Since C++ allows us to create hierarchy-related objects, we can build special object oriented libraries which can be used later by many programmers.  While C++ is able to map the real-world problem properly, the C part of C++ gives the language the ability to get close to the machine-level details.  C++ programs are easily maintainable and expandable. When a new feature needs to be implemented, it is very easy to add to the existing structure of an object. Simple C++ Program: Program Features: Like C, the C++ program is a collection of functions. The above example contains only one function, main(). Execution begin at main(). Every C++ program must have a main(). C++ is a free-form language, the C++ statements terminate with semicolons. Comments: C++ introduces a new comment symbol // (double slash). A comment may start anywhere in the line, and whatever follows till the end of the line is ignored. There is no closing symbol. The double slash comment is basically a single line comment. Multi line comments can be written follows: // this is an example file // C++ program to illustrate // some of it’s feature The C comment symbol /*, / are still valid are more suitable for multi line comments. The following command is allowed. / this is an example of C++ program to illustrates Some of it’s features */

include // include header file

int main() { cout<<” C++ is better than C.\n”; // C++ statement return 0; } // end of example

Output Operator:

The output statement  cout << “C++ is better than C.”; causes the string in quotation marks to be displayed on the screen. This statement introduces two new C++ features, cout and <<. The identifier cout(pronounced as ‘C out’) is a predefined object that represents the standard output stream in C++. The operator << is called the insertion or put to operator. It inserts (or sends) the content of the variable on it’s to the rights of the object on it’s left (figure). Object insertion operator variable Figure: Output using insertion operator The operator << is the bit-wise left-shift operator and it can still be used for this purpose. This is an example of how one operator can be used for different purposes, depending on the context. This concept is known as operator overloading.

Input operator:

The statement  cin >> number1; The operator >> is known as extraction or get from operator. It extracts (or takes) the value form the keyboard and assign it to the variable on it’s right(figure). Object Extraction Operator Variable Keyboard Figure. Input using Extraction operator

Cascading of I/O operators:

The statement  cout <<”Sum = “< This directive causes the preprocessor to add the contents of the iostream file to the program. It contains declarations for the identifier cout and the operator <<. Some old versions of C++ use a header file called iostream.h. The header file iostream should be included at the beginning of all programs that use input/output statements.

Cout <<

“C++”

Cin >>

Variables:

Variables are locations in the memory that can hold values. Before assigning any value to a variable, it must be declared. To use the variable number storing an integer value, the variable number must be declared and it should be of the type int as follows: int number ;

Constants:

Constants refer to fixed values that do not change during the execution of a program. Like C, C++ support several kinds of literal constants. They include integers, characters, floating point numbers and string. Example: 123 // decimal integer 12.34 // floating point integer O37 // octal integer OX2 // hexadecimal integer “C++” // string constant ‘A’ // character constant

Basic Data Types:

Data types in C++ can be classified under various categories as shown in Fig. Figure- Hierarchy of C++ data types With the exception of void, the basic data types may have several modifiers preceding them to serve the needs of various situations. The modifiers signed, unsigned, long, and short may be applied to character and integer basic data types. However, the modifier long may also be applied to double. Size and Range of C++ Basic Data types Type Bytes Range Use char 1 - 128 to +127 Used to store single character unsigned char 1 0 to 255 Used to store unsigned (positive only) single character signed char 1 - 128 to +127 Used to store signed (both positive and negative) single character int 2 - 32,768 to + 32,767 (- 215 to 2^15 - 1) Used to store integer (whole numbers) values unsigned int 2 0 to 65,535 Used to store unsigned integer (positive whole numbers) values signed int 2 - 32,768 to + 32,767 (- 215 to 2^15 - 1) Used to store signed integer (whole numbers both positive and negative) values C++ Data Types Derived type array function pointer reference User-defined type structure union class enumeration Built-in type Integer Type Void Floating type int char float double

short int 2 - 32,768 to + 32,767 (- 215 to 2^15 - 1) Used to store short integer (whole numbers) values unsigned short int 2 0 to 65,535 Used to store unsigned short integer (positive whole numbers) values signed short int 2 - 32,768 to + 32,767 (- 215 to 2^15 - 1) Used to store signed short integer (whole numbers both positive and negative) values long int 4 - 2,147,483,648 to +2,147,483,647 Used to store long integer (whole numbers) values signed long int 4 - 2,147,483,648 to +2,147,483,647 Used to store unsigned long integer (positive whole numbers) values unsigned long int 4 0 to 4,294,967,295 Used to store signed long integer (whole numbers both positive and negative) values float 4 3.4E-38 to 3.4E+38 Used to store numbers with decimal point with single precision. double 8 1.7E-308 to 1.7E+308 Used to store numbers with decimal point with double precision. long double 10 3.4E-4932 to 1.1E+4932 Used to store numbers with decimal point with more than double precision. Void: The normal use of void is (1) To specify the return type of a function when it is not returning any value and (2) To indicate an empty argument list to a function. Example: void funct1(void);

User—Defined Data Types:

Structures and Classes:

  1. struct  To store structure
  2. union  To store union C++ also permits us to define another user-defined data type known as class which can be used, just like any other basic data type, to declare variables. The class variables are known as objects. Enumerated Data Type: An enumerated data type is another user-defined type which provides a way for attaching names to numbers, thereby increasing comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2 and so on. The syntax of an enum statement is similar to that of the struct statement. Ex: enum shape { circle, square, triangle }; enum color { red, green, blue, yellow }; By default, the enumerators are assigned integer values starting with 0 for the first enumerator, 1 for the second, and so on. For example, enum color{red, blue=4, green=8}; enum color{red=5, blue, green}; are valid definitions. In first case, red is 0 by default. In the second case, blue is 6 and green is 7.

Derived Data Types:

Arrays: An array is a group of like-typed variables that are referred to by a common name. The compiler will allow declaring the array size as the exact length of the string constant. Ex : char string[3]= ”xyz”; is valid in C. It assumes that the programmer to leave out the null character \0 in the definition. But in C++, the size should be one larger than the number of characters in the string. char string[4]= ”xyz”;

Dynamic Initialization Variables:

C++, permits initialization of the variable at run time. this is referred to as dynamic initialization. Example: Normal declaration Dynamic Declaration ……. …… ……. …… int n; int n=strlen(string); n=strlen(string); …… float area; ……. area=3.14159radrad; float area=3.14159radrad; Dynamic initialization is extensively used in object-oriented programming. We can create exactly the type of object needed, using information that is known only at the run time.

Reference Variables:

C++ introduces a new kind of variable known as the reference variable. A reference variable provides an alias (alternative name) for a previously defined variable. For example, if we make the variable sum a reference to the variable total , then sum and total can be used interchangeably to represent that variable. The reference variable created as follows: data-type & reference-name=variable-name;

C++ assigns additional meaning to the symbol &. Here, & is not an address operator. The notation float &

means reference to float. Example, int n[10]; int & x = n[10]; // x is alias for n[10] char & a =’\n’; // initialize reference to a literal the variable x is an alternative to the array element n[10]. The variable a is initialized to the newline constant. The following reference are also allowed i. int x; ii. int &n=50; int p=&x; int &m=p; the first set of declarations causes m to refer to x which is pointed to by the pointer p and the statement in ii. Creates an int object with value 50 and name n. A major application of reference variables is in passing arguments to functions. Consider the following: void f( int & x) // uses reference { x =x+10; // x is incremented; so also m } int main() { int m=10; f(m); // function call

} when the function is call f(m) is executed, the following initialization occurs: int &x = m; such function calls are known as call by reference. Since the variable x and m are aliases, when the function increments x , m is also incremented. The value of m becomes 20 after the function is executed. one location two names x int & x = m; call m 10 int m = 10 f(m)

Operators:

C++ has a rich set of operators. All operators in C are valid in C++ also.

a. Assignment Operators b. Arithmetic Operators

c. Relational Operators d. Logical Operators

d. Bit wise Operators e. Increment/Decrement operators

f. Shortcut Operators g. Conditional Operators

h. Special operators

Assignment operators: The assignment operator is used to store the constants, variables, and result of an expression and return value of a function from right side into variable placed in left side.

Operator : = Ex : a = 6; a = b; a = b+c;

Arithmetic operators: The arithmetic operators perform the basic arithmetic operations such as addition, subtraction, multiplication, division and modulus.

The operators are : +, – , , /, % Ex : x=a+b, x=a-b, x=ab, x=a/b, x=a%b

Unary operators: The operators that work with only one operand are called as unary operators. The operators used in

C++ language are : +, – , ++, – – ,!.

Increment/Decrement operators:

The Increment operators ++ increase the value of operand by one.

The Decrement operators -- decrease the value of operand by one.

Ex : i++, ++i, i--, --i. Shortcut assignment operators: When same variable is used in both left and right side of an arithmetic expression, we can use the shortcut assignment operators.

The operators are : +=, – =, =, /=, %= Ex : a += b, a – =b, a=b, a/=b, a%=b

Sizeof and Comma operators: The sizeof operator returns the memory size occupied by an operand in terms of bytes.

Ex : a = sizeof(int) ;

The comma operator ( , ) adjoins several expressions. Ex : x = (y = 3, y + 1);

Conditional operators:

The ?: are conditional operators. They do the job done by if..else control structure.

Syntax : expression1? expression2 : expression3; Ex : big = (a>b)? a : b;

Relational operators:

The operators that do relationship tests with the operands are called relational operators.

The relational operators are:

< (less than)  Ex : if(a < b)

<= (less than or equal to)  Ex : if(a <= b)

> (greater than)  Ex : if(a > b)

>= (greater than or equal to)  Ex : if(a >= b)

== (is equal to)  Ex : if(a == b)

!= (not equal to)  Ex : if(a != b)

Logical operators: Logical operators are used when more than one relationship should be considered in evaluation. It gives either True value or False value.

AND operator : &&  AND Ex: if((a>b) && (a>c)) Truth table for AND, OR:

OR operator : ||  OR Ex: if((a>b) || (a>b))

NOT operator :!  NOT Ex: if(!(a>b))

Truth table of NOT :

A B A&&B A || B

A! A