SlideShare a Scribd company logo
5
Most read
8
Most read
19
Most read
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

PPTX
C++ decision making
PPTX
PPTX
Operator in c programming
PDF
FUNCTIONS IN C PROGRAMMING.pdf
PPTX
PPTX
Loops in c language
PPTX
Nested loops
PPT
Storage classes
C++ decision making
Operator in c programming
FUNCTIONS IN C PROGRAMMING.pdf
Loops in c language
Nested loops
Storage classes

What's hot (20)

PPT
Control structure C++
PPTX
PPT
pre processor directives in C
PDF
Infix to postfix expression in ds
DOC
Report on c
PDF
Function in C
PPTX
Increment and Decrement operators in C++
PPT
History of c++
PPTX
Operators and expressions
PPTX
Storage classes in C
PPSX
C lecture 4 nested loops and jumping statements slideshare
PPT
Chapter 5 -Syntax Directed Translation - Copy.ppt
PPTX
Tokens in C++
PPTX
Lexical analyzer generator lex
PPT
2. operators in c
PPTX
Operator.ppt
PPTX
Introduction to c++
PPT
Algorithms and flowcharts ppt (seminar presentation)..
PPTX
C++ string
ODP
Operators
Control structure C++
pre processor directives in C
Infix to postfix expression in ds
Report on c
Function in C
Increment and Decrement operators in C++
History of c++
Operators and expressions
Storage classes in C
C lecture 4 nested loops and jumping statements slideshare
Chapter 5 -Syntax Directed Translation - Copy.ppt
Tokens in C++
Lexical analyzer generator lex
2. operators in c
Operator.ppt
Introduction to c++
Algorithms and flowcharts ppt (seminar presentation)..
C++ string
Operators
Ad

Viewers also liked (7)

PDF
03. oop concepts
PDF
04. constructor & destructor
PPTX
Constructor and destructor
PPTX
constructor & destructor in cpp
PPTX
Constructors & destructors
PPTX
Constructor and destructor in c++
PDF
How to Become a Thought Leader in Your Niche
03. oop concepts
04. constructor & destructor
Constructor and destructor
constructor & destructor in cpp
Constructors & destructors
Constructor and destructor in c++
How to Become a Thought Leader in Your Niche
Ad

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

PPTX
Lecture # 1 - Introduction Revision - 1 OOPS.pptx
PDF
Lecture # 1 introduction revision - 1
PPT
C++ basic.ppt
PPT
02a fundamental c++ types, arithmetic
PDF
02. functions & introduction to class
PPTX
C++ overview
PPT
chap1cpp3rd.ppt
PPT
A Powerpoint Presentation on CPP Programming
PPT
CPLUSPLUS UET PESHAWAR BS ELECTRICAL 2ND SEMSTER Lecture02.ppt
PDF
3.-Beginnign-with-C.pdf.Basic c++ Learn and Object oriented programming a to z
PPT
C++ Language
PPT
keyword
PPT
keyword
PPT
CPP Language Basics - Reference
PDF
From Novice To Ninja Mastering Dsa In C Pabitra Banerjee
PPTX
cppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjj
PPT
Chapter2
PPTX
c++ introduction, array, pointers included.pptx
Lecture # 1 - Introduction Revision - 1 OOPS.pptx
Lecture # 1 introduction revision - 1
C++ basic.ppt
02a fundamental c++ types, arithmetic
02. functions & introduction to class
C++ overview
chap1cpp3rd.ppt
A Powerpoint Presentation on CPP Programming
CPLUSPLUS UET PESHAWAR BS ELECTRICAL 2ND SEMSTER Lecture02.ppt
3.-Beginnign-with-C.pdf.Basic c++ Learn and Object oriented programming a to z
C++ Language
keyword
keyword
CPP Language Basics - Reference
From Novice To Ninja Mastering Dsa In C Pabitra Banerjee
cppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjj
Chapter2
c++ introduction, array, pointers included.pptx

Recently uploaded (20)

PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Trump Administration's workforce development strategy
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Lesson notes of climatology university.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Cell Types and Its function , kingdom of life
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Trump Administration's workforce development strategy
Complications of Minimal Access Surgery at WLH
Lesson notes of climatology university.
Final Presentation General Medicine 03-08-2024.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Cell Types and Its function , kingdom of life
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Paper A Mock Exam 9_ Attempt review.pdf.
Final Presentation General Medicine 03-08-2024.pptx
Orientation - ARALprogram of Deped to the Parents.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