SlideShare a Scribd company logo
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1
Haresh Jaiswal
Rising Technologies, Jalna.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2
Agenda
 Introduction
 Input/Output
 Manipulators
 Reference Variables
 C++ Data Types
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3
Origin of C++
 C++ began as an expanded version of C.
 The C++ extensions were first invented by Bjarne
Stroustrup in 1979 at Bell Laboratories.
 Initially called the new language "C with Classes”
 Later in 1983 the name was changed to “C++”
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4
Origin of C++
 Over the years, computer programs have become larger
and more complex.
 Even though C is an excellent programming language, it
has its limits. In C, once a program exceeds from 25,000
to 100,000 lines of code, it becomes so complex that it is
difficult to grasp as a totality.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5
Origin of C++
 Although C was one of the most liked and widely used
professional programming languages in the world, the
invention of C++ was necessitated by one major
programming factor: increasing complexity.
 The essence of C++ is to allow the programmer to
manage larger, more complex programs.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6
Input/Output in C++
 The most common way in which a program
communicates with the outside world is through simple,
character oriented Input/Output (IO) operations.
 C++ provides two useful operators for this purpose:
 >> for input and
 << for output.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7
Input/Output in C++
 Every C++ Program must include the header ‘iostream.h’
It contains declarations for the stream objects
 cout & cin
 stream insertion & stream extraction operators.
 << (Stream insertion)
 >> (Stream Extraction)
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8
Input/Output in C++
 An Example of console output using cout & << operator
cout << “Hello”;
 Causes the string in quotation mark to be displayed on
the screen/console.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9
Input/Output in C++

cout << “Hello…”
VariableInsertion
operator
Object
Hello…
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10
Input/Output in C++
 An Example of console input using cin & >> operator.
cin >> myVariable;
 Will receive input from keyboard and store it in
myVariable
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11
Input/Output in C++
cin >> 45.6
Object
Extraction
Operator
myVariable

Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12
Manipulators
 Manipulators are operators that are used to format the
output data display. The most commonly used
manipulators are…
 endl
 setw
 setprecision
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13
Manipulators
 The endl manipulator, when used in an output statement,
causes a line feed to be inserted. It has the same effect as
using the newline ‘n’ in ‘C’.
cout << “Rising Technologies” << endl;
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14
Manipulators
int a = 2314, b = 28, c = 327;
cout << “A = ” << a << endl;
cout << “B = “ << b << endl;
cout << “C = “ << c << endl;
 Above code will print 3 lines of output as follows
A = 2314
B = 28
C = 327
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15
Manipulators
A = 2314
B = 28
C = 327
 But above form is not ideal, it should rather appear like
this,
A = 2314
B = 28
C = 327
 Here output is right aligned.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16
Manipulators
A = 2314
B = 28
C = 327
 Above form of output is possible only if we specify a
common field width for all the numbers and force them
to print right aligned.
 setw manipulator can do this job.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17
Manipulators
int myVariable = 372;
cout << setw(5) << myVariable;
 The manipulator setw(5) specifies a field width 5 for
printing the value of myVariable, this value is right
justified within the field.
3 7 2
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18
Manipulators
setprecision(argument);
 The setprecision manipulator sets the floating-point
precision to the specified argument.
float myVariable = 1.123456;
cout << setprecision(2) << myVariable;
 Will print following output
1.12
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 19
Reference Variable.
 A ‘Reference Variable’ provides an Alias (Alternate Name)
for a previously defined variable.
int a = 10;
int &r = a;
// in above statement „r‟ is declared as
reference to „a‟, hence
r++;
 Will increase both ‘a’ & ‘r’ by 1
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 20
Reference Variable.
int &r = a;
 After this declaration ‘a’ and ‘r’ both refer to the same
memory location, as if they were the same variable.
int a = 10;
10
Variable in memory
int &r = a;
One location two names
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 21
Reference Variable.
 Notice that a reference does not create a copy of an
object/variable, it simply provides an alias/alternate
name for it, Hence after following declaration…
int &r = a;
 Both ‘a’ and ‘r’ will refer to same memory location.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 22
Reference Variable.
 A Reference must be initialized when it is declared, it
must be an alias for something upon declaration.
 It would be illegal to declare a reference variable and
then initialize it later.
int a;
int &r; // illegal : reference without initializer
r = a;
int a;
int &r = a; // legal
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 23
C++ Data Types
Derived Types
Array
Function
Pointer
Reference
User defined
Types
Structure
Union
Class
Enumeration
Built In Types
Empty Type Floating TypesIntegral Types
Int char float double
C++ Data Types
void

More Related Content

What's hot

CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
trupti1976
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
Rajab Ali
 
Advance java summer training report
Advance java summer training report Advance java summer training report
Advance java summer training report
Nitesh Saini
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
Võ Hòa
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
jini james
 
C# in depth
C# in depthC# in depth
C# in depth
Arnon Axelrod
 
C++ oop
C++ oopC++ oop
C++ oop
Sunil OS
 
sSCOPE RESOLUTION OPERATOR.pptx
sSCOPE RESOLUTION OPERATOR.pptxsSCOPE RESOLUTION OPERATOR.pptx
sSCOPE RESOLUTION OPERATOR.pptx
Nidhi Mehra
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
SudhanshuVijay3
 
C programming for problem solving
C programming for problem solving  C programming for problem solving
C programming for problem solving
Anuradha Moti T
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
Sivakumar R D .
 
core java
core javacore java
core java
Roushan Sinha
 
Lecture 1- History of C Programming
Lecture 1- History of C Programming Lecture 1- History of C Programming
Lecture 1- History of C Programming
Md. Imran Hossain Showrov
 

What's hot (20)

CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
C# basics
 C# basics C# basics
C# basics
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Advance java summer training report
Advance java summer training report Advance java summer training report
Advance java summer training report
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
Report on c
Report on cReport on c
Report on c
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
 
C# in depth
C# in depthC# in depth
C# in depth
 
C++ oop
C++ oopC++ oop
C++ oop
 
C vs c++
C vs c++C vs c++
C vs c++
 
sSCOPE RESOLUTION OPERATOR.pptx
sSCOPE RESOLUTION OPERATOR.pptxsSCOPE RESOLUTION OPERATOR.pptx
sSCOPE RESOLUTION OPERATOR.pptx
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
 
C programming for problem solving
C programming for problem solving  C programming for problem solving
C programming for problem solving
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
 
core java
core javacore java
core java
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Lecture 1- History of C Programming
Lecture 1- History of C Programming Lecture 1- History of C Programming
Lecture 1- History of C Programming
 

Viewers also liked

03. oop concepts
03. oop concepts03. oop concepts
03. oop concepts
Haresh Jaiswal
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructorHaresh Jaiswal
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
Shubham Vishwambhar
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
gourav kottawar
 
Constructor and destructor in c++
Constructor and destructor in c++Constructor and destructor in c++
Constructor and destructor in c++
Learn By Watch
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 

Viewers also liked (7)

03. oop concepts
03. oop concepts03. oop concepts
03. oop concepts
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Constructor and destructor in c++
Constructor and destructor in c++Constructor and destructor in c++
Constructor and destructor in c++
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar to 01. introduction to C++

02. functions & introduction to class
02. functions & introduction to class02. functions & introduction to class
02. functions & introduction to class
Haresh Jaiswal
 
DATA ABSTRACTION.pptx
DATA ABSTRACTION.pptxDATA ABSTRACTION.pptx
DATA ABSTRACTION.pptx
ManavSharma694627
 
c.ppt
c.pptc.ppt
C++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIAC++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIA
Dheeraj Kataria
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
WatchDog13
 
C++ functions
C++ functionsC++ functions
C++ functions
Mayank Jain
 
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
Thooyavan Venkatachalam
 
C++
C++C++
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
SHRIRANG PINJARKAR
 
Cling the llvm based interpreter
Cling the llvm based interpreterCling the llvm based interpreter
Cling the llvm based interpreter
Roberto Nogueira
 
C++ Functions
C++ FunctionsC++ Functions
C++ Functions
sathish sak
 
CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
SukhpreetSingh519414
 
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
GrejoJoby1
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
gamingwithfaulty
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
Marco Izzotti
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
somu rajesh
 

Similar to 01. introduction to C++ (20)

02. functions & introduction to class
02. functions & introduction to class02. functions & introduction to class
02. functions & introduction to class
 
DATA ABSTRACTION.pptx
DATA ABSTRACTION.pptxDATA ABSTRACTION.pptx
DATA ABSTRACTION.pptx
 
c.ppt
c.pptc.ppt
c.ppt
 
C++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIAC++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIA
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C++
C++C++
C++
 
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
 
Cling the llvm based interpreter
Cling the llvm based interpreterCling the llvm based interpreter
Cling the llvm based interpreter
 
C++ Functions
C++ FunctionsC++ Functions
C++ Functions
 
CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
 
Chap 3 c++
Chap 3 c++Chap 3 c++
Chap 3 c++
 
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
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 

Recently uploaded

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

01. introduction to C++

  • 1. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1 Haresh Jaiswal Rising Technologies, Jalna.
  • 2. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2 Agenda  Introduction  Input/Output  Manipulators  Reference Variables  C++ Data Types
  • 3. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3 Origin of C++  C++ began as an expanded version of C.  The C++ extensions were first invented by Bjarne Stroustrup in 1979 at Bell Laboratories.  Initially called the new language "C with Classes”  Later in 1983 the name was changed to “C++”
  • 4. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4 Origin of C++  Over the years, computer programs have become larger and more complex.  Even though C is an excellent programming language, it has its limits. In C, once a program exceeds from 25,000 to 100,000 lines of code, it becomes so complex that it is difficult to grasp as a totality.
  • 5. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5 Origin of C++  Although C was one of the most liked and widely used professional programming languages in the world, the invention of C++ was necessitated by one major programming factor: increasing complexity.  The essence of C++ is to allow the programmer to manage larger, more complex programs.
  • 6. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6 Input/Output in C++  The most common way in which a program communicates with the outside world is through simple, character oriented Input/Output (IO) operations.  C++ provides two useful operators for this purpose:  >> for input and  << for output.
  • 7. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7 Input/Output in C++  Every C++ Program must include the header ‘iostream.h’ It contains declarations for the stream objects  cout & cin  stream insertion & stream extraction operators.  << (Stream insertion)  >> (Stream Extraction)
  • 8. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8 Input/Output in C++  An Example of console output using cout & << operator cout << “Hello”;  Causes the string in quotation mark to be displayed on the screen/console.
  • 9. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9 Input/Output in C++  cout << “Hello…” VariableInsertion operator Object Hello…
  • 10. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10 Input/Output in C++  An Example of console input using cin & >> operator. cin >> myVariable;  Will receive input from keyboard and store it in myVariable
  • 11. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11 Input/Output in C++ cin >> 45.6 Object Extraction Operator myVariable 
  • 12. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12 Manipulators  Manipulators are operators that are used to format the output data display. The most commonly used manipulators are…  endl  setw  setprecision
  • 13. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13 Manipulators  The endl manipulator, when used in an output statement, causes a line feed to be inserted. It has the same effect as using the newline ‘n’ in ‘C’. cout << “Rising Technologies” << endl;
  • 14. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14 Manipulators int a = 2314, b = 28, c = 327; cout << “A = ” << a << endl; cout << “B = “ << b << endl; cout << “C = “ << c << endl;  Above code will print 3 lines of output as follows A = 2314 B = 28 C = 327
  • 15. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15 Manipulators A = 2314 B = 28 C = 327  But above form is not ideal, it should rather appear like this, A = 2314 B = 28 C = 327  Here output is right aligned.
  • 16. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16 Manipulators A = 2314 B = 28 C = 327  Above form of output is possible only if we specify a common field width for all the numbers and force them to print right aligned.  setw manipulator can do this job.
  • 17. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17 Manipulators int myVariable = 372; cout << setw(5) << myVariable;  The manipulator setw(5) specifies a field width 5 for printing the value of myVariable, this value is right justified within the field. 3 7 2
  • 18. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18 Manipulators setprecision(argument);  The setprecision manipulator sets the floating-point precision to the specified argument. float myVariable = 1.123456; cout << setprecision(2) << myVariable;  Will print following output 1.12
  • 19. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 19 Reference Variable.  A ‘Reference Variable’ provides an Alias (Alternate Name) for a previously defined variable. int a = 10; int &r = a; // in above statement „r‟ is declared as reference to „a‟, hence r++;  Will increase both ‘a’ & ‘r’ by 1
  • 20. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 20 Reference Variable. int &r = a;  After this declaration ‘a’ and ‘r’ both refer to the same memory location, as if they were the same variable. int a = 10; 10 Variable in memory int &r = a; One location two names
  • 21. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 21 Reference Variable.  Notice that a reference does not create a copy of an object/variable, it simply provides an alias/alternate name for it, Hence after following declaration… int &r = a;  Both ‘a’ and ‘r’ will refer to same memory location.
  • 22. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 22 Reference Variable.  A Reference must be initialized when it is declared, it must be an alias for something upon declaration.  It would be illegal to declare a reference variable and then initialize it later. int a; int &r; // illegal : reference without initializer r = a; int a; int &r = a; // legal
  • 23. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 23 C++ Data Types Derived Types Array Function Pointer Reference User defined Types Structure Union Class Enumeration Built In Types Empty Type Floating TypesIntegral Types Int char float double C++ Data Types void