SlideShare a Scribd company logo
1 of 23
EXPRESSION
Chap 3
1By:-Gourav Kottawar
Contents
3.1 Tokens, Keywords, Identifiers & Constants,
3.2 Basic Data Types, User-Defined Data Types,
3.3 Symbolic Constant, Type Compatibility,
3.4 Reference Variables, Operator in C++,
3.5 Scope Resolution Operator,
3.6 Member De-referencing Operators,
3.7 Memory Management Operators,
3.8 Manipulators, Type Cast Operator
2
By:-Gourav Kottawar
Structure of C++ Program
3
By:-Gourav Kottawar
Tokens
The smallest individual units in a program are
known as tokens.
C++ has the following tokens :
Keywords
Identifiers
Strings
operators
4
By:-Gourav Kottawar
Keywords
5
By:-Gourav Kottawar
Identifiers and Constants
6
By:-Gourav Kottawar
3.2 Basic Data Types, User-Defined Data Types,
 Primitive Built-in Types
Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t
7
By:-Gourav Kottawar
 Several of the basic types can be modified
using one or more of these type modifiers:
 signed
 unsigned
 short
 long
8
By:-Gourav Kottawar
Type Typical Bit Width Typical Range
char 1byte -127 to 127
unsigned char 1byte 0 to 255
signed char 1byte -128 to 127
int 2bytes -32768 to 32767
unsigned int 2bytes 0 to 65,535
signed int 2bytes -32768 to 32767
short int 2bytes -32768 to 32767
unsigned short
int
2 byte 0 to 65,535
signed short int 2 byte -32768 to 32767
long int 4bytes
-2,147,483,647 to
2,147,483,647
signed long int 4bytes same as long int
unsigned long
int
4bytes 0 to 4,294,967,295
float 4bytes +/- 3.4e +/- 38 (~7 digits)
double 8bytes +/- 1.7e +/- 308 (~15 digits)
long double 8bytes +/- 1.7e +/- 308 (~15 digits)
wchar_t 2 or 4 bytes 1 wide character
9 By:-Gourav Kottawar
#include <iostream>
using namespace std;
int main()
{
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
cout << "Size of wchar_t : " << sizeof(wchar_t) << endl; return 0;
}
10
By:-Gourav Kottawar
typedef Declarations:
 You can create a new name for an existing
type using typedef.
 Syntax : typedef type newname;
For example, the following tells the compiler that feet is another name
for int:
typedef int feet;
Now, the following declaration is perfectly legal
and creates an integer variable called
distance:
feet distance;
11
By:-Gourav Kottawar
Enumerated Types:
 An enumerated type declares an optional type
name and a set of zero or more identifiers that
can be used as values of the type. Each
enumerator is a constant whose type is the
enumeration.
 Syntax - enum enum-name { list of names }
var-list;
 Ex- enum color { red, green, blue } c;
c = blue;
enum color { red, green=5, blue };
12
By:-Gourav Kottawar
3.4 Reference Variables
 A reference variable is an alias, that is, another
name for an already existing variable.
 Once a reference is initialized with a variable,
either the variable name or the reference
name may be used to refer to the variable.
 Creating References in C++:
int i = 17;
We can declare reference variables for i as
follows.
int& r = i;
13
By:-Gourav Kottawar
#include <iostream>
using namespace std;
int main ()
{ // declare simple variables
int i;
double d;
// declare reference variables
int& r = i;
double& s = d;
i = 5;
cout << "Value of i : " << i << endl;
cout << "Value of i reference : " << r << endl;
d = 11.7;
cout << "Value of d : " << d << endl;
cout << "Value of d reference : " << s << endl;
return 0; }
14 By:-Gourav Kottawar
Operators in C++
 All c operators are valid in c++.
 <<
 >>
 :: Scope resolution operator
 ::* Pointer to member declarator
 ->*Pointer to member operator
 .* Pointer to member operator
 delete
 endl
 new
 setw
15
By:-Gourav Kottawar
Memory Management Operator
new
Pointer_variable = new data-type;
Ex- p = new int;
int *p= new int;
We can also initialize the memory
using the new operator
Pointer_variable = new data-
type(value);
Ex- int *p=new int (25);
16
By:-Gourav Kottawar
Memory Management Operator
One dimensional array
Pointer_variable = new data-type[size];
int *p=new int[10];
Multidimensional array
array_ptr = new int[3][5][4];
array_ptr = new int[m][5][4];
17
By:-Gourav Kottawar
Memory Management Operator
 delete
delete destroyed to release the memory space
for reuse.
delete pointer_variable;
Ex - delete p;
Free a dynamically allocated array
delete [size] pointer_variable;
Ex- delete []p;
18
By:-Gourav Kottawar
Memory Management Operator
 Advantages of new operator
1. It automatically computes size of the data
object. No need of sizeof.
2. It automatically returns the correct pointer
type, no need to use type cast.
3. It is possible to initialize the object while
creating the memory space.
4. new , delete can be overloaded.
19
By:-Gourav Kottawar
Manipulators
 Input manipulators
 Output manipulators
 Parameterized manipulators
20
By:-Gourav Kottawar
Typecast operators
 Syntax
Typename (expression)
Avg= sum/float (i);
21
By:-Gourav Kottawar
Special assignment expression
 Chained assignment
X=(y=0);
Or
X=y=0;
 Embedded assignment
X=(y=50)+10
22
By:-Gourav Kottawar
Control structure
 Simple if statement
 if.....else statement
 switch statement
 do….while
 while
 for
23
By:-Gourav Kottawar

More Related Content

What's hot

Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 

What's hot (19)

Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Function
FunctionFunction
Function
 
c programming
c programmingc programming
c programming
 
Managing console i/o operation,working with files
Managing console i/o operation,working with filesManaging console i/o operation,working with files
Managing console i/o operation,working with files
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
c programming
c programmingc programming
c programming
 
Functional Programming with Javascript
Functional Programming with JavascriptFunctional Programming with Javascript
Functional Programming with Javascript
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 
ERC20 Token Contract
ERC20 Token ContractERC20 Token Contract
ERC20 Token Contract
 
Arrays
ArraysArrays
Arrays
 
The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
functions of C++
functions of C++functions of C++
functions of C++
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
 
Pointer in c++ part3
Pointer in c++ part3Pointer in c++ part3
Pointer in c++ part3
 
Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 
CODEsign 2015
CODEsign 2015CODEsign 2015
CODEsign 2015
 
The Ring programming language version 1.2 book - Part 9 of 84
The Ring programming language version 1.2 book - Part 9 of 84The Ring programming language version 1.2 book - Part 9 of 84
The Ring programming language version 1.2 book - Part 9 of 84
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 

Viewers also liked

Business Card Designer
Business Card DesignerBusiness Card Designer
Business Card Designer
NextBee Media
 

Viewers also liked (20)

Simulacro examen censal 1
Simulacro examen censal 1Simulacro examen censal 1
Simulacro examen censal 1
 
Uni papua fc kuta gle aceh held exhibition match with putra seulawah fc.
Uni papua fc kuta gle aceh held exhibition match with putra seulawah fc.Uni papua fc kuta gle aceh held exhibition match with putra seulawah fc.
Uni papua fc kuta gle aceh held exhibition match with putra seulawah fc.
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Kit comunicación-entrada-3-oralidad
Kit comunicación-entrada-3-oralidadKit comunicación-entrada-3-oralidad
Kit comunicación-entrada-3-oralidad
 
Wind power
Wind powerWind power
Wind power
 
Matriz de Registro de Comunicación 1
Matriz de Registro de Comunicación 1Matriz de Registro de Comunicación 1
Matriz de Registro de Comunicación 1
 
2009
20092009
2009
 
Business Card Designer
Business Card DesignerBusiness Card Designer
Business Card Designer
 
El Amor Nunca Deja De Ser
El Amor Nunca Deja De SerEl Amor Nunca Deja De Ser
El Amor Nunca Deja De Ser
 
C++ functions
C++ functionsC++ functions
C++ functions
 
软件项目管理与团队合作
软件项目管理与团队合作软件项目管理与团队合作
软件项目管理与团队合作
 
Digitalisation@Massey: Understanding the Real Drivers
Digitalisation@Massey: Understanding the Real DriversDigitalisation@Massey: Understanding the Real Drivers
Digitalisation@Massey: Understanding the Real Drivers
 
Canal de distribuição
Canal de distribuiçãoCanal de distribuição
Canal de distribuição
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cpp
 
LEGADO UNIVERSAL DEL SHABBAT
LEGADO UNIVERSAL DEL SHABBATLEGADO UNIVERSAL DEL SHABBAT
LEGADO UNIVERSAL DEL SHABBAT
 
Bautismo verdadero
Bautismo verdaderoBautismo verdadero
Bautismo verdadero
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
 
Lavori Elisabetta Frameglia per corso graphic design
Lavori Elisabetta Frameglia per corso graphic designLavori Elisabetta Frameglia per corso graphic design
Lavori Elisabetta Frameglia per corso graphic design
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
 
[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP
 

Similar to expression in cpp

2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
Warui Maina
 

Similar to expression in cpp (20)

operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
 
operator overloading & type conversion in cpp
operator overloading & type conversion in cppoperator overloading & type conversion in cpp
operator overloading & type conversion in cpp
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
C++
C++C++
C++
 
Pointer
PointerPointer
Pointer
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
Managing console input and output
Managing console input and outputManaging console input and output
Managing console input and output
 
Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
C++ programming
C++ programmingC++ programming
C++ programming
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
 
Statement
StatementStatement
Statement
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
chapter-11-pointers.pdf
chapter-11-pointers.pdfchapter-11-pointers.pdf
chapter-11-pointers.pdf
 

More from gourav kottawar

More from gourav kottawar (20)

constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
classes & objects in cpp
classes & objects in cppclasses & objects in cpp
classes & objects in cpp
 
expression in cpp
expression in cppexpression in cpp
expression in cpp
 
basics of c++
basics of c++basics of c++
basics of c++
 
working file handling in cpp overview
working file handling in cpp overviewworking file handling in cpp overview
working file handling in cpp overview
 
pointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpppointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpp
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
basics of c++
basics of c++basics of c++
basics of c++
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sql
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slides
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overview
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
 
Relational Model in dbms & sql database
Relational Model in dbms & sql databaseRelational Model in dbms & sql database
Relational Model in dbms & sql database
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
 
security and privacy in dbms and in sql database
security and privacy in dbms and in sql databasesecurity and privacy in dbms and in sql database
security and privacy in dbms and in sql database
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)
 
Software documentation
Software documentationSoftware documentation
Software documentation
 
Software reengineering
Software reengineeringSoftware reengineering
Software reengineering
 
Organizational behaviour
Organizational behaviourOrganizational behaviour
Organizational behaviour
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

expression in cpp

  • 2. Contents 3.1 Tokens, Keywords, Identifiers & Constants, 3.2 Basic Data Types, User-Defined Data Types, 3.3 Symbolic Constant, Type Compatibility, 3.4 Reference Variables, Operator in C++, 3.5 Scope Resolution Operator, 3.6 Member De-referencing Operators, 3.7 Memory Management Operators, 3.8 Manipulators, Type Cast Operator 2 By:-Gourav Kottawar
  • 3. Structure of C++ Program 3 By:-Gourav Kottawar
  • 4. Tokens The smallest individual units in a program are known as tokens. C++ has the following tokens : Keywords Identifiers Strings operators 4 By:-Gourav Kottawar
  • 7. 3.2 Basic Data Types, User-Defined Data Types,  Primitive Built-in Types Type Keyword Boolean bool Character char Integer int Floating point float Double floating point double Valueless void Wide character wchar_t 7 By:-Gourav Kottawar
  • 8.  Several of the basic types can be modified using one or more of these type modifiers:  signed  unsigned  short  long 8 By:-Gourav Kottawar
  • 9. Type Typical Bit Width Typical Range char 1byte -127 to 127 unsigned char 1byte 0 to 255 signed char 1byte -128 to 127 int 2bytes -32768 to 32767 unsigned int 2bytes 0 to 65,535 signed int 2bytes -32768 to 32767 short int 2bytes -32768 to 32767 unsigned short int 2 byte 0 to 65,535 signed short int 2 byte -32768 to 32767 long int 4bytes -2,147,483,647 to 2,147,483,647 signed long int 4bytes same as long int unsigned long int 4bytes 0 to 4,294,967,295 float 4bytes +/- 3.4e +/- 38 (~7 digits) double 8bytes +/- 1.7e +/- 308 (~15 digits) long double 8bytes +/- 1.7e +/- 308 (~15 digits) wchar_t 2 or 4 bytes 1 wide character 9 By:-Gourav Kottawar
  • 10. #include <iostream> using namespace std; int main() { cout << "Size of char : " << sizeof(char) << endl; cout << "Size of int : " << sizeof(int) << endl; cout << "Size of short int : " << sizeof(short int) << endl; cout << "Size of long int : " << sizeof(long int) << endl; cout << "Size of float : " << sizeof(float) << endl; cout << "Size of double : " << sizeof(double) << endl; cout << "Size of wchar_t : " << sizeof(wchar_t) << endl; return 0; } 10 By:-Gourav Kottawar
  • 11. typedef Declarations:  You can create a new name for an existing type using typedef.  Syntax : typedef type newname; For example, the following tells the compiler that feet is another name for int: typedef int feet; Now, the following declaration is perfectly legal and creates an integer variable called distance: feet distance; 11 By:-Gourav Kottawar
  • 12. Enumerated Types:  An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration.  Syntax - enum enum-name { list of names } var-list;  Ex- enum color { red, green, blue } c; c = blue; enum color { red, green=5, blue }; 12 By:-Gourav Kottawar
  • 13. 3.4 Reference Variables  A reference variable is an alias, that is, another name for an already existing variable.  Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.  Creating References in C++: int i = 17; We can declare reference variables for i as follows. int& r = i; 13 By:-Gourav Kottawar
  • 14. #include <iostream> using namespace std; int main () { // declare simple variables int i; double d; // declare reference variables int& r = i; double& s = d; i = 5; cout << "Value of i : " << i << endl; cout << "Value of i reference : " << r << endl; d = 11.7; cout << "Value of d : " << d << endl; cout << "Value of d reference : " << s << endl; return 0; } 14 By:-Gourav Kottawar
  • 15. Operators in C++  All c operators are valid in c++.  <<  >>  :: Scope resolution operator  ::* Pointer to member declarator  ->*Pointer to member operator  .* Pointer to member operator  delete  endl  new  setw 15 By:-Gourav Kottawar
  • 16. Memory Management Operator new Pointer_variable = new data-type; Ex- p = new int; int *p= new int; We can also initialize the memory using the new operator Pointer_variable = new data- type(value); Ex- int *p=new int (25); 16 By:-Gourav Kottawar
  • 17. Memory Management Operator One dimensional array Pointer_variable = new data-type[size]; int *p=new int[10]; Multidimensional array array_ptr = new int[3][5][4]; array_ptr = new int[m][5][4]; 17 By:-Gourav Kottawar
  • 18. Memory Management Operator  delete delete destroyed to release the memory space for reuse. delete pointer_variable; Ex - delete p; Free a dynamically allocated array delete [size] pointer_variable; Ex- delete []p; 18 By:-Gourav Kottawar
  • 19. Memory Management Operator  Advantages of new operator 1. It automatically computes size of the data object. No need of sizeof. 2. It automatically returns the correct pointer type, no need to use type cast. 3. It is possible to initialize the object while creating the memory space. 4. new , delete can be overloaded. 19 By:-Gourav Kottawar
  • 20. Manipulators  Input manipulators  Output manipulators  Parameterized manipulators 20 By:-Gourav Kottawar
  • 21. Typecast operators  Syntax Typename (expression) Avg= sum/float (i); 21 By:-Gourav Kottawar
  • 22. Special assignment expression  Chained assignment X=(y=0); Or X=y=0;  Embedded assignment X=(y=50)+10 22 By:-Gourav Kottawar
  • 23. Control structure  Simple if statement  if.....else statement  switch statement  do….while  while  for 23 By:-Gourav Kottawar