SlideShare a Scribd company logo
Object Oriented
Programming using C++
UGCA 1909
What is C++?
► C++ is a cross-platform language that can be used to create high-performance
applications.
► C++ was developed by Bjarne Stroustrup, as an extension to the C language.
► C++ gives programmers a high level of control over system resources and
memory.
Why Use C++?
► C++ is one of the world's most popular programming languages.
► C++ can be found in today's operating systems, Graphical User Interfaces, and
embedded systems.
► C++ is an object-oriented programming language which gives a clear structure to
programs and allows code to be reused, lowering development costs.
► C++ is portable and can be used to develop applications that can be adapted to
multiple platforms.
► C++ is fun and easy to learn!
Introduction to C++ Programming
Language
► C++ is a general-purpose programming language that was developed as an
enhancement of the C language to include object-oriented paradigm.
► It is a compiled language.
C vs. C++
What is C?
► C is a structural or procedural oriented programming language which is
machine-independent and extensively used in various applications.
► C is the basic programming language that can be used to develop from the
operating systems (like Windows) to complex programs like Oracle database,
Python interpreter, and many more.
► If we know the C language, then we can easily learn other programming
languages.
► C language was developed by the great computer scientist Dennis Ritchie at
the Bell Laboratories.
► It contains some additional features that make it unique from other
programming languages.
What is C++?
► C++ is a special-purpose programming language developed by Bjarne
Stroustrup at Bell Labs circa 1980.
► C++ language is very similar to C language, and it is so compatible with C that
it can run 99% of C programs without changing any source of code though C++
is an object-oriented programming language, so it is safer and well-structured
programming language than C.
C vs. C++
No. C C++
1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and object
oriented.
2) Data is less secured in C. In C++, you can use modifiers for class members to make it
inaccessible for outside users.
3) C follows the top-down approach. C++ follows the bottom-up approach.
4) C does not support function overloading. C++ supports function overloading.
5) In C, you can't use functions in structure. In C++, you can use functions in classes.
6) C does not support reference variables. C++ supports reference variables.
7) In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and
output operations.
8) Operator overloading is not possible in C. Operator overloading is possible in C++.
9) C programs are divided into procedures and modules C++ programs are divided into functions and classes.
10) C does not provide the feature of namespace. C++ supports the feature of namespace.
11) Exception handling is not easy in C. It has to perform using other
functions.
C++ provides exception handling using Try and Catch block.
12) C does not support the inheritance. C++ supports inheritance.
C++ history
► C++ programming language was developed in 1980 by Bjarne Stroustrup at bell
laboratories of AT&T (American Telephone & Telegraph), located in U.S.A.
► It was developed for adding a feature of OOP (Object Oriented Programming)
in C without significantly changing the C component.
► C++ programming is "relative" (called a superset) of C, it means any valid C
program is also a valid C++ program.
The History of C++
BCPL 196
7
B 197
0
C 197
2
C++
ANSI C
198
9
198
3
Martin Richards.
No types
Ken Thompson
Dennis Ritchie
Some Types
The standard.
Strong Typing
Bjarne Stroustrup
OOP
C++ Features
► C++ is object oriented programming language. It provides a lot of features that are
given below.
1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. Structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible
11. Object Oriented
12. Compiler based
C++ Features
Explanation
1) Simple
► C++ is a simple language in the sense that it provides structured approach (to
break the problem into parts), rich set of library functions, data types etc.
2) Machine Independent or Portable
► Unlike assembly language, c programs can be executed in many machines
with little bit or no change. But it is not platform-independent.
► A C++ program is not platform-independent (compiled programs on Linux
won't run on Windows), however they are machine independent.
3) Mid-level programming language
► C++ is also used to do low level programming. It is used to develop system
applications such as kernel, driver etc. It also supports the feature of high
level language. That is why it is known as mid-level language.
4) Structured programming language
► C++ is a structured programming language in the sense that we can break the
program into parts using functions. So, it is easy to understand and modify.
5) Rich Library
► C++ provides a lot of inbuilt functions that makes the development fast.
6) Memory Management
► It supports the feature of dynamic memory allocation. In C++ language, we can free
the allocated memory at any time by calling the free() function.
7) Speed
► The compilation and execution time of C++ language is fast.
8) Pointer
► C++ provides the feature of pointers. We can directly interact with the memory by
using the pointers. We can use pointers for memory, structures, functions, array
etc.
9) Recursion
► In C++, we can call the function within the function. It provides code reusability for
every function.
10) Extensible
► C++ language is extensible because it can easily adopt new features.
11) Object Oriented
► C++ is object oriented programming language. OOPs makes development and
maintenance easier where as in Procedure-oriented programming language it is not
easy to manage if code grows as project size grows.
12) Compiler based
► C++ is a compiler based programming language, it means without compilation no
C++ program can be executed. First we need to compile our program using compiler
and then we can execute our program.
OOPs (Object Oriented Programming
System)
► Object means a real word entity such as pen, chair, table etc.
► Object-Oriented Programming is a methodology or paradigm to design a program
using classes and objects.
► It simplifies the software development and maintenance by providing some
concepts:
► Object
► Class
► Inheritance
► Polymorphism
► Abstraction
► Encapsulation
OOPs Concepts
► Object
Any entity that has state and behavior is known as an object. For example: chair, pen,
table, keyboard, bike etc. It can be physical and logical.
► Class
Collection of objects is called class. It is a logical entity.
► Inheritance
When one object acquires all the properties and behaviours of parent object i.e. known as
inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
► Polymorphism
When one task is performed by different ways i.e. known as polymorphism. For example: to
convince the customer differently, to draw something e.g. shape or rectangle etc.
In C++, we use Function overloading and Function overriding to achieve polymorphism.
► Abstraction
Hiding internal details and showing functionality is known as abstraction. For
example: phone call, we don't know the internal processing.
In C++, we use abstract class and interface to achieve abstraction.
► Encapsulation
Binding (or wrapping) code and data together into a single unit is known as
encapsulation. For example: capsule, it is wrapped with different medicines.
Advantage of OOPs over
Procedure-oriented programming
language
► OOPs makes development and maintenance easier where as in
Procedure-oriented programming language it is not easy to manage if code
grows as project size grows.
► OOPs provide data hiding whereas in Procedure-oriented programming
language a global data can be accessed from anywhere.
► OOPs provide ability to simulate real-world event much more effectively. We
can provide the solution of real word problem if we are using the
Object-Oriented Programming language.
Turbo C++ - Download & Installation
► There are many compilers available for C++. You need to download any one.
Here, we are going to use Turbo C++. It will work for both C and C++. To
install the Turbo C++ software, you need to follow following steps.
► Download Turbo C++
► Create turboc directory inside c drive and extract the tc3.zip inside c:turboc
► Double click on install.exe file
► Click on the tc application file located inside c:TCBIN to write the c program
C++ Program
#include <iostream.h>
#include<conio.h>
void main() {
clrscr();
cout << "Welcome to C++ Programming.";
getch();
}
Explanation
► #include<iostream.h> includes the standard input output library functions. It
provides cin and cout methods for reading from input and writing to output
respectively.
► #include <conio.h> includes the console input output library functions. The getch()
function is defined in conio.h file.
► void main() The main() function is the entry point of every program in C++ language.
The void keyword specifies that it returns no value.
► cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++
Programming." on the console.
► getch() The getch() function asks for a single character. Until you press any key, it
blocks the screen.
How to compile and run the C++ program
► There are 2 ways to compile and run the C++ program, by menu and by shortcut.
► By menu
Now click on the compile menu then compile sub menu to compile the c++ program.
► Then click on the run menu then run sub menu to run the c++ program.
► By shortcut
Or, press ctrl+f9 keys compile and run the program directly.
Output screen
You can view the user screen any time by pressing the alt+f5 keys.
C++ Basic Input/Output
► C++ I/O operation is using the stream concept. Stream is the sequence of
bytes or flow of data. It makes the performance fast.
► If bytes flow from main memory to device like printer, display screen, or a
network connection, etc, this is called as output operation.
► If bytes flow from device like printer, display screen, or a network
connection, etc to main memory, this is called as input operation.
► <iostream> It is used to define the cout, cin and cerr objects, which
correspond to standard output stream, standard input stream and standard
error stream, respectively.
Standard output stream (cout)
► The cout is a predefined object of ostream class.
► It is connected with the standard output device, which is usually a display
screen.
► The cout is used in conjunction with stream insertion operator (<<) to display
the output on a console.
#include <iostream>
using namespace std;
int main( ) {
char a[] = "Welcome to C++ ";
cout << "Value of ary is: " << a << endl;
}
Output:
Value of a is: Welcome to C++
Standard input stream (cin)
► The cin is a predefined object of istream class.
► It is connected with the standard input device, which is usually a keyboard.
► The cin is used in conjunction with stream extraction operator (>>) to read
the input from a console.
#include <iostream>
using namespace std;
int main( ) {
int age;
cout << "Enter your age: ";
cin >> age;
cout << "Your age is: " << age << endl;
}
Output:
Enter your age: 22
Your age is: 22
Standard end line (endl)
► The endl is a predefined object of ostream class. It is used to insert a new
line characters and flushes the stream.
#include <iostream>
using namespace std;
int main( ) {
cout << "C++ ";
cout << " Program"<<endl;
cout << "End of line"<<endl;
}
Output:
C++ Program
End of line
Object oriented programming c++

More Related Content

PDF
C++ OOPS Concept
PPTX
Object Oriented Programming using C++(UNIT 1)
PPTX
Object Oriented Programming
PDF
Introduction to oops concepts
PPTX
Presentation on-exception-handling
PPTX
Oop c++class(final).ppt
PPT
Visual basic
PPTX
Object Oriented Programming Using C++
C++ OOPS Concept
Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming
Introduction to oops concepts
Presentation on-exception-handling
Oop c++class(final).ppt
Visual basic
Object Oriented Programming Using C++

What's hot (20)

PPTX
Pointers in C Programming
PPTX
Data types in C
PPTX
Presentation on C++ Programming Language
PPTX
Python Functions
PPTX
Structure in C
PPTX
Looping statement in python
PPTX
C++ Overview PPT
PPTX
Recursive Function
PDF
Operators in python
PPTX
Data types in python
PPT
Basic concept of OOP's
PDF
Introduction to c++ ppt 1
PDF
Control statements
PPT
RECURSION IN C
PPTX
Functions in c++
PPTX
Encapsulation C++
PDF
Datatypes in python
PDF
Function overloading ppt
PDF
Introduction to Python
ODP
Python Modules
Pointers in C Programming
Data types in C
Presentation on C++ Programming Language
Python Functions
Structure in C
Looping statement in python
C++ Overview PPT
Recursive Function
Operators in python
Data types in python
Basic concept of OOP's
Introduction to c++ ppt 1
Control statements
RECURSION IN C
Functions in c++
Encapsulation C++
Datatypes in python
Function overloading ppt
Introduction to Python
Python Modules
Ad

Similar to Object oriented programming c++ (20)

PPTX
object oriented programming language fundamentals
PPTX
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
PPTX
Unit 1 of c++ part 1 basic introduction
PPTX
Procedure Oriented programming Object Oriented programming Basic Concept of ...
PPTX
Summer training PPT Manasv Singharia.pptx
PPT
Payal C++ ppt presentation.ppt college class
PPTX
1. Introduction to C++ and brief history
PPTX
Introduction to c++ programming language
PPTX
c programming, internshala training , govt engineering college aurangabad
PPTX
C++ vs C#
PPTX
C++ helps you to format the I/O operations like determining the number of dig...
PPTX
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
PDF
Introduction-to-C-Part-1.pdf
PPTX
C++Basics2022.pptx
PPTX
Session 1 - c++ intro
DOC
Introduction-to-C-Part-1 (1).doc
PDF
PPTX
Advantage and Disadvantages of C++ programming.pptx
PPTX
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
PPTX
Introduction-to-C-Part-1.pptx
object oriented programming language fundamentals
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
Unit 1 of c++ part 1 basic introduction
Procedure Oriented programming Object Oriented programming Basic Concept of ...
Summer training PPT Manasv Singharia.pptx
Payal C++ ppt presentation.ppt college class
1. Introduction to C++ and brief history
Introduction to c++ programming language
c programming, internshala training , govt engineering college aurangabad
C++ vs C#
C++ helps you to format the I/O operations like determining the number of dig...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
Introduction-to-C-Part-1.pdf
C++Basics2022.pptx
Session 1 - c++ intro
Introduction-to-C-Part-1 (1).doc
Advantage and Disadvantages of C++ programming.pptx
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1.pptx
Ad

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Basic Mud Logging Guide for educational purpose
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Institutional Correction lecture only . . .
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
Microbial disease of the cardiovascular and lymphatic systems
Anesthesia in Laparoscopic Surgery in India
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
VCE English Exam - Section C Student Revision Booklet
Basic Mud Logging Guide for educational purpose
Abdominal Access Techniques with Prof. Dr. R K Mishra
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Supply Chain Operations Speaking Notes -ICLT Program
Institutional Correction lecture only . . .
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
102 student loan defaulters named and shamed – Is someone you know on the list?

Object oriented programming c++

  • 2. What is C++? ► C++ is a cross-platform language that can be used to create high-performance applications. ► C++ was developed by Bjarne Stroustrup, as an extension to the C language. ► C++ gives programmers a high level of control over system resources and memory.
  • 3. Why Use C++? ► C++ is one of the world's most popular programming languages. ► C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. ► C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. ► C++ is portable and can be used to develop applications that can be adapted to multiple platforms. ► C++ is fun and easy to learn!
  • 4. Introduction to C++ Programming Language ► C++ is a general-purpose programming language that was developed as an enhancement of the C language to include object-oriented paradigm. ► It is a compiled language.
  • 5. C vs. C++ What is C? ► C is a structural or procedural oriented programming language which is machine-independent and extensively used in various applications. ► C is the basic programming language that can be used to develop from the operating systems (like Windows) to complex programs like Oracle database, Python interpreter, and many more. ► If we know the C language, then we can easily learn other programming languages. ► C language was developed by the great computer scientist Dennis Ritchie at the Bell Laboratories. ► It contains some additional features that make it unique from other programming languages.
  • 6. What is C++? ► C++ is a special-purpose programming language developed by Bjarne Stroustrup at Bell Labs circa 1980. ► C++ language is very similar to C language, and it is so compatible with C that it can run 99% of C programs without changing any source of code though C++ is an object-oriented programming language, so it is safer and well-structured programming language than C.
  • 7. C vs. C++ No. C C++ 1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and object oriented. 2) Data is less secured in C. In C++, you can use modifiers for class members to make it inaccessible for outside users. 3) C follows the top-down approach. C++ follows the bottom-up approach. 4) C does not support function overloading. C++ supports function overloading. 5) In C, you can't use functions in structure. In C++, you can use functions in classes. 6) C does not support reference variables. C++ supports reference variables. 7) In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and output operations. 8) Operator overloading is not possible in C. Operator overloading is possible in C++. 9) C programs are divided into procedures and modules C++ programs are divided into functions and classes. 10) C does not provide the feature of namespace. C++ supports the feature of namespace. 11) Exception handling is not easy in C. It has to perform using other functions. C++ provides exception handling using Try and Catch block. 12) C does not support the inheritance. C++ supports inheritance.
  • 8. C++ history ► C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. ► It was developed for adding a feature of OOP (Object Oriented Programming) in C without significantly changing the C component. ► C++ programming is "relative" (called a superset) of C, it means any valid C program is also a valid C++ program.
  • 9. The History of C++ BCPL 196 7 B 197 0 C 197 2 C++ ANSI C 198 9 198 3 Martin Richards. No types Ken Thompson Dennis Ritchie Some Types The standard. Strong Typing Bjarne Stroustrup OOP
  • 10. C++ Features ► C++ is object oriented programming language. It provides a lot of features that are given below. 1. Simple 2. Machine Independent or Portable 3. Mid-level programming language 4. Structured programming language 5. Rich Library 6. Memory Management 7. Fast Speed 8. Pointers 9. Recursion 10. Extensible 11. Object Oriented 12. Compiler based
  • 12. Explanation 1) Simple ► C++ is a simple language in the sense that it provides structured approach (to break the problem into parts), rich set of library functions, data types etc. 2) Machine Independent or Portable ► Unlike assembly language, c programs can be executed in many machines with little bit or no change. But it is not platform-independent. ► A C++ program is not platform-independent (compiled programs on Linux won't run on Windows), however they are machine independent.
  • 13. 3) Mid-level programming language ► C++ is also used to do low level programming. It is used to develop system applications such as kernel, driver etc. It also supports the feature of high level language. That is why it is known as mid-level language. 4) Structured programming language ► C++ is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify. 5) Rich Library ► C++ provides a lot of inbuilt functions that makes the development fast.
  • 14. 6) Memory Management ► It supports the feature of dynamic memory allocation. In C++ language, we can free the allocated memory at any time by calling the free() function. 7) Speed ► The compilation and execution time of C++ language is fast. 8) Pointer ► C++ provides the feature of pointers. We can directly interact with the memory by using the pointers. We can use pointers for memory, structures, functions, array etc. 9) Recursion ► In C++, we can call the function within the function. It provides code reusability for every function.
  • 15. 10) Extensible ► C++ language is extensible because it can easily adopt new features. 11) Object Oriented ► C++ is object oriented programming language. OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. 12) Compiler based ► C++ is a compiler based programming language, it means without compilation no C++ program can be executed. First we need to compile our program using compiler and then we can execute our program.
  • 16. OOPs (Object Oriented Programming System) ► Object means a real word entity such as pen, chair, table etc. ► Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. ► It simplifies the software development and maintenance by providing some concepts: ► Object ► Class ► Inheritance ► Polymorphism ► Abstraction ► Encapsulation
  • 17. OOPs Concepts ► Object Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical. ► Class Collection of objects is called class. It is a logical entity. ► Inheritance When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. ► Polymorphism When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. In C++, we use Function overloading and Function overriding to achieve polymorphism.
  • 18. ► Abstraction Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing. In C++, we use abstract class and interface to achieve abstraction. ► Encapsulation Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.
  • 19. Advantage of OOPs over Procedure-oriented programming language ► OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. ► OOPs provide data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere. ► OOPs provide ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.
  • 20. Turbo C++ - Download & Installation ► There are many compilers available for C++. You need to download any one. Here, we are going to use Turbo C++. It will work for both C and C++. To install the Turbo C++ software, you need to follow following steps. ► Download Turbo C++ ► Create turboc directory inside c drive and extract the tc3.zip inside c:turboc ► Double click on install.exe file ► Click on the tc application file located inside c:TCBIN to write the c program
  • 21. C++ Program #include <iostream.h> #include<conio.h> void main() { clrscr(); cout << "Welcome to C++ Programming."; getch(); }
  • 22. Explanation ► #include<iostream.h> includes the standard input output library functions. It provides cin and cout methods for reading from input and writing to output respectively. ► #include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file. ► void main() The main() function is the entry point of every program in C++ language. The void keyword specifies that it returns no value. ► cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++ Programming." on the console. ► getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.
  • 23. How to compile and run the C++ program ► There are 2 ways to compile and run the C++ program, by menu and by shortcut. ► By menu Now click on the compile menu then compile sub menu to compile the c++ program. ► Then click on the run menu then run sub menu to run the c++ program. ► By shortcut Or, press ctrl+f9 keys compile and run the program directly.
  • 24. Output screen You can view the user screen any time by pressing the alt+f5 keys.
  • 25. C++ Basic Input/Output ► C++ I/O operation is using the stream concept. Stream is the sequence of bytes or flow of data. It makes the performance fast. ► If bytes flow from main memory to device like printer, display screen, or a network connection, etc, this is called as output operation. ► If bytes flow from device like printer, display screen, or a network connection, etc to main memory, this is called as input operation. ► <iostream> It is used to define the cout, cin and cerr objects, which correspond to standard output stream, standard input stream and standard error stream, respectively.
  • 26. Standard output stream (cout) ► The cout is a predefined object of ostream class. ► It is connected with the standard output device, which is usually a display screen. ► The cout is used in conjunction with stream insertion operator (<<) to display the output on a console. #include <iostream> using namespace std; int main( ) { char a[] = "Welcome to C++ "; cout << "Value of ary is: " << a << endl; } Output: Value of a is: Welcome to C++
  • 27. Standard input stream (cin) ► The cin is a predefined object of istream class. ► It is connected with the standard input device, which is usually a keyboard. ► The cin is used in conjunction with stream extraction operator (>>) to read the input from a console. #include <iostream> using namespace std; int main( ) { int age; cout << "Enter your age: "; cin >> age; cout << "Your age is: " << age << endl; } Output: Enter your age: 22 Your age is: 22
  • 28. Standard end line (endl) ► The endl is a predefined object of ostream class. It is used to insert a new line characters and flushes the stream. #include <iostream> using namespace std; int main( ) { cout << "C++ "; cout << " Program"<<endl; cout << "End of line"<<endl; } Output: C++ Program End of line