SlideShare a Scribd company logo
1 of 42
S.Y.B.C.A.(Science)
BCA 241-Object Oriented Programming And C++
Unit 1
Introduction to C++
Prepared by:
Prof. Shashi Jadhav
Modern college, Ganeshkhind,Pune.
Introduction
• What is Programming Language?
A programming language is a type of written language that tells
computers what to do.
Examples are: Python, Ruby, Java, JavaScript, C, C++, and C#.
Programming languages are used to write all computer programs and
computer software.
• Types of Computer Languages
1. Machine level
2. Assembly level
3. High level
High level languages
1. Procedure Oriented: C, Fortran,COBOL, VB, and Pascal.
2 Object oriented: Java, C++, VB.NET, Python, and C#.NET.
Procedure-oriented programming.
• Programming in the high-level languages such as COBOL, FORTRAN, C,
etc. is known as procedure-oriented programming.
• Procedure-oriented programming basically contains group of
instructions known as function. There are multiple functions into the
program.
• In below figure we have divided our program into multiple functions.
• We use flowchart or algorithm to show how the program is executed
from one instruction to other instruction.
• It doesn’t emphasize on the data.
• In a multi-function program we use
global variable to communicate
between two functions.
• Global variable can be use by any
function at any time while local
variables are only used within the
function.
• But it creates problem in large
program because we can’t
determine which global variables
(data) are used by which function.
• Also global variables are accessed
by all the function so any function
can change its value at any time so
all the function will be affected.
Characteristics of procedure-oriented
programming language:
• It emphasis on algorithm (focus is on doing things/functions ).
• Large programs are divided into smaller programs known as
functions. Hence the program consist of multiple functions.
• Most of the Functions share global data.
• Data is not hidden, it move freely from one function to another
function.
• Functions change the value of data at any time from any place.
(Functions transform data from one form to another.)
• Hence no data security.
• It uses top-down programming approach.
Drawbacks Of POP
• POP has two major drawbacks, viz.
• (1) data move freely around the program and are therefore
vulnerable to changes caused by any function in the program, and
• (2) it does not model very well the real-world problems.
Object-oriented programming
• Object-oriented programming
(OOP) is a computer programming
model that organizes software
design around data, or objects,
rather than functions and logic.
• OOP allows decomposition of a
problem into a number of entities
called objects and then builds data
& functions around these objects.
• The data of an object can be
accessed by only the function
associated with that object.
• However functions of one object
can be accessed by functions of
another object.
Object-oriented programming
• Striking features of object oriented programming are :
• Emphasis is on data rather than procedure.
• Programs are divided into objects.
• Data structures are designed such that they characterize the objects.
• Functions that operate on the data of an object are tied together in
the data structure.
• Data is hidden and cannot be accessed by external functions.
• Objects may communicate with each other through functions.
• New data and functions can be easily added whenever necessary.
• Follows bottom-up approach in program design.
BASIC CONCEPTS OF OBJECT-ORIENTED
PROGRAMMING
The basic concepts of object oriented programming include :
• Objects
• Classes
• Data abstraction and encapsulation
• Inheritance
• Polymorphism
• Data binding
• Message passing.
Advantages of OOP
• Re-usability: Write once and use it multiple times, you can achieve this by using
class.
• Redundancy: This is a condition created at the place of data storage (you can say
Databases)where the same piece of data is held in two separate places. So the
data redundancy is one of the greatest advantages of OOP. If a user wants a
similar functionality in multiple classes, he/she can go ahead by writing common
class definitions for similar functionalities and inherit them.
• Easy Maintenance: It is easy to maintain and modify existing code, as new objects
can be created with small differences to existing ones.
• Code Flexibility
The flexibility is offered through the concept of Polymorphism.
• Security: Using data hiding and abstraction only necessary data will be provided,
thus maintains the security of data.
Disadvantages of OOP:
• Size: Object-Oriented Programs are much larger than other programs.
• Effort: Object-Oriented Programs require a lot of work to create.
• Speed: Object-Oriented Programs are slower than other programs,
because of their size.
Applications of object oriented programming
• 1.Developing graphical user interface
• 2.System Applications
• 3. Object oriented database system
• 4.Expert Systems
• 5. Simulation and modelling softwares
• 6. Artificial intelligence
• 7 Compiler construction
• 8 CAD/CAM software
OOP Vs POP
Sr. No. Key OOP POP
1
Definition OOP stands for Object Oriented
Programing.
POP stands for Procedural
Oriented Programming.
2 Approach OOP follows bottom up approach. POP follows top down approach.
3
Division A program is divided to objects
and their interactions.
A program is divided into funtions
and they interacts.
4
Inheritance
supported
Inheritance is supported. Inheritance is not supported.
5
Access
control
Access control is supported via
access modifiers.
No access modifiers are
supported.
6
Data Hiding Encapsulation is used to hide data. No data hiding present. Data is
globally accessible.
7 Example C++, Java C, Pascal
Introduction to C++
It is an object oriented programming language.
Evolved in 1979,by Bjarne Stroustrup at AT & T Bell laboratories.
It is based on an object oriented language Simula67 and C language.
C++ is an extention of C with a major addition of the class construct
feature of Simula67.
Initially it was called as C with classes.
In 1983 it was renamed as C++(incremented version of C)
C++ is a superset of C
Backward compatible to C i.e. Almost all C programs are also C++
programs.
Applications of C++
• Versatile language for handling very large programs.
• Suitable for development of editors, databases, System programs.
• Useful for developing good libraries which can be later used by many
programmers.
• C++ is used in developing browsers, operating systems, and
applications, as well as in-game programming, software engineering,
data structures, etc.
• JVM(virtual machine of Java) and python interpreter are written in
C++.
Advantages of C++ Over Other Languages
• 1. Object-Oriented
C++ is an object-oriented programming language which means that the main focus is on objects and manipulations around
these objects. This makes it much easier to manipulate code, unlike procedural or structured programming which requires a
series of computational steps to be carried out.
• 2. Speed
When speed is a critical metric, C++ is the most preferred choice. The compilation and execution time of a C++ program is
much faster than most general-purpose programming languages.
• 3. Compiled
Unlike other programming languages where no compilation is required, every C++ code has to be first compiled to a low-level
language and then executed. Hence faster and more efficient to execute than interpreted languages.
• 4. Rich Library Support
The C++ Standard Template Library (STL) has many functions available to help write code quickly. For example, there are STLs
for various containers like hash tables, maps, sets, etc.
• 5. Pointer Support
C++ also supports pointers which are often not available in other programming languages.
• 6. Closer to Hardware
C++ is closer to hardware than most general-purpose programming languages. This makes it very useful in those areas where
hardware and software are closely coupled together, and low-level support is needed at the software level. Developer has
more control over hardware aspects, like memory management and CPU usage.
Features of C++
1) Simple
C++ is a simple language because it provides a structured approach (to
break the problem into parts), a rich set of library functions, data types,
etc.
2) Abstract Data types
In C++, complex data types called Abstract Data Types (ADT) can be
created using classes.
3) Portable
• C++ is a portable language and programs made in it can be run on
different machines.
Features of C++
4) Mid-level / Intermediate programming language
C++ includes both low-level programming and high-level language so it is known as
a mid-level and intermediate programming language. It is used to develop system
applications such as kernel, driver, etc.
5) Structured programming language
C++ is a structured programming language. In this we can divide the program into
several parts using functions.
6) Rich Library
C++ provides a lot of inbuilt functions that make the development fast. Following
are the libraries used in C++ programming are:
• <iostream>
• <cmath>
• <cstdlib>
• <fstream>
Features of C++
7) Memory Management
• C++ provides very efficient management techniques. The various memory
management operators help save the memory and improve the program's
efficiency. These operators allocate and deallocate memory at run time.
Some common memory management operators available C++ are new,
delete etc.
8) Quicker Compilation
• C++ programs tend to be compact and run quickly. Hence the compilation
and execution time of the C++ language is fast.
9) Pointer
• C++ provides the feature of pointers. We can use pointers for memory,
structures, functions, array, etc. We can directly interact with the memory
by using the pointers.
10) Recursion
• In C++, we can call the function within the function. It provides code
reusability for every function.
Features of C++
11) Extensible
• C++ programs can easily be extended as it is very easy to add new
features into the existing program.
12) Object-Oriented
• In C++, object-oriented concepts like data hiding, encapsulation, and
data abstraction can easily be implemented using keyword class,
private, public, and protected access specifiers. Object-oriented
makes development and maintenance easier.
13) Compiler based
• C++ is a compiler-based programming language, which means no C++
program can be executed without compilation. C++ compiler is easily
available, and it requires very little space for storage. First, we need to
compile our program using a compiler, and then we can execute our
program.
Features of C++
14) Reusability
• With the use of inheritance of functions programs written in C++ can be
reused in any other program of C++. You can save program parts into
library files and invoke them in your next programming projects simply by
including the library files. New programs can be developed in lesser time as
the existing code can be reused. It is also possible to define several
functions with same name that perform different task. For Example: abs ()
is used to calculate the absolute value of integer, float and long integer.
• 15) Redefine Existing Operators
• C++ allows the programmer to redefine the meaning of existing operators
such as +, -. For Example, The "+" operator can be used for adding two
numbers and concatenating two strings.
Features of C++
16)National Standards
• C++ has national standards such as ANSI. (American National
Standards Institute)
17) Errors are easily detected
• It is easier to maintain a C++ programs as errors can be easily located
and rectified. It also provides a feature called exception handling to
support error handling in your program.
18) Clarity
• The keywords and library functions used in C++ resemble common
English words.
Features of C++
19) Power and Flexibility
• C++ is a powerful and flexible language because of most of the
powerful flexible and modern UNIX operating system is written in
C++. Many compilers and interpreters for other languages such as
FORTRAN, PERL, Python, PASCAL, BASIC, LISP, etc., have been written
in C++. C++ programs have been used for solving physics and
engineering problems and even for animated special effects for
movies.
20) Modelling real-world problems
• The programs written in C++ are well suited for real-world modeling
problems as close as possible to the user perspective.
Differences between C and C++:
• Definition
C is a structural programming language, and it does not support classes and
objects, while C++ is an object-oriented programming language that supports the
concept of classes and objects.
• Type of programming language
C is procedure oriented programming language(POP) , while C++ is an object-
oriented programming language(OOP).
• Subset
C++ is a superset of C programming language. C++ can run 99% of C code but C
language cannot run C++ code.
• Type of approach
C follows the top-down approach, while C++ follows the bottom-up approach.
The top-down approach breaks the main modules into tasks; these tasks are
broken into sub-tasks, and so on. The bottom-up approach develops the lower
level modules first and then the next level modules.
Differences between C and C++:
• Keywords
C contains 32 keywords, and C++ supports 63 keywords.(81 as of C++20)
• Security
In C, the data can be easily manipulated by the outsiders as it does not support
the encapsulation and information hiding while C++ is a very secure language,
i.e., no outsiders can manipulate its data as it supports both encapsulation and
data hiding. In C language, functions and data are the free entities, and in C++
language, all the functions and data are encapsulated in the form of objects.
• Exception handling
C does not provide direct support to the exception handling; it needs to use
functions that support exception handling. C++ provides direct support to
exception handling by using a try-catch block.
• Input/Output functions
In C, scanf and printf functions are used for input and output operations,
respectively, while in C++, cin and cout are used for input and output operations,
respectively.
Differences between C and C++:
• Memory allocation and de-allocation
C supports calloc() and malloc() functions for the memory allocation, and free()
function for the memory de-allocation. C++ supports a new operator for the
memory allocation and delete operator for the memory de-allocation.
• Header file
C program uses <stdio.h> header file while C++ program
uses <iostream.h> header file.
• Namespace feature
A namespace is a feature that groups the entities like classes, objects, and
functions under some specific name. C does not contain the namespace feature,
while C++ supports the namespace feature that avoids the name collisions.
Writing and executing a C++ Program
Step1.
Creating source code Using Vi Editor :
• Open terminal
• write command vi filename.cpp” for C++ (“vi filename.c” For C)
• Enter “I” , to activate insert mode in vi editor .
• Write your code
• Enter “Esc”
• Enter “:”
• write “wq” ,Enter.
• Now source file is created with .cpp extention
• Step 2:
• Compiling the source code:
• The source file has to be converted into machine code using a
compiler. For this we can use Turbo C++ or GNU C++ Compiler
• Using GNU C++ Compiler gcc or g++:
• for cpp code write “g++ - o filename filename.cpp” , Or write “g++
filename.cpp”
• (for c code write “gcc - o filename filename.c” ,Enter)
• After compiling a runnable file will be created which is called
object file .(with extention .o/.obj)
• Step3:
• Linking the object code to create an Executable code-
• After compilation the object file is given to linker.
• This program combines the files, add necessary libraries and creates
an executable file with extension .exe
• Step4
• Executing the Program
• Once the executable file is created, you can run it by typing its name
at the DOS command prompt or through the option provided by the
compiler software.
• In linux /centos you can write ./filename or ./a.out and press enter.
Simple C++ Program • #include <iostream> is Directives for
preprocessor:
• A namespace is a feature that groups
the entities like classes, objects, and
functions under some specific name.
• As the same name can’t be given to
multiple variables, functions, classes,
etc. in the same scope.
• So to overcome this situation
namespace is introduced.
• namespace defines a scope of that
entity.
• std is a namespace whose members
are used in the program
the members of the “std” namespace
are cout, cin, endl, etc.
• int main() : It is Function Signatures
#include <iostream>
using namespace std;
namespace sybca // first name space
{
void show_topper()
{ cout << "Raj is topper"<< endl;
}
}
// second name space
namespace tybca
{
void show_topper()
{
cout << "Radha is topper"<< endl;
}
}
using namespace sybca;
int main ()
{
show_topper();
return 0;
}
•What is output ??
•Rewrite same program
without using
namespace
Directives: #include <iostream>
• In the first line, the file iostream is included into the current .cpp file.
The hashtag (#) signals to a program called the preprocessor which
reads through your source code, looking for all the lines that begin
the with # symbol. The command #include tells the preprocessor
“find the file iostream, read it, and place it here.” The angle brackets
(<>) surrounding the file name tells the preprocessor to look in the
usual places for this file. If your compiler is set up properly, all the
include files are in one repository.
• The file iostream is used by cout, which writes to the console. The
effect of #include <iostream> is to include the file iostream into this
C++ program as if you typed it in yourself.
Function Signatures: int main()
• The actual program begins with the function main(). Every C++ program
needs to have a main() function because when you execute your program,
main() is called automatically.
• A function’s signature is important because it defines the inputs and
outputs of the function. In int main(), the first part int states that the
main() function returns an interger value to the operating system. This
function achieves that because, at the bottom, it executes return 0.
• Note: The compiler will allow you to return other data types. However, for
main(), the only legal return type is int. Generally, it is the informal
convention to return 0 to express that the program has ended without
errors.
The Function Body & Namespaces
• All functions begin with an opening brace ({) and end with a closing brace
(}). Everything in between the braces is considered to be part of that
function.
• cout and cin are used in C++ to handle input (such as user input from a
keyboard) and output (such as printing to the console).
• cout and cin objects provided by the standard library (std)
• The standard library is the standard collection of objects that comes with
every C++ compiler.
• By using the namespace specifier std,
You tell the compiler that the cout object you can use is part of the standard
library
Assignment 1
• Q1. Explain features of C++ language?
• Q2.What are advantages of C++ ?
• Q3. What is Procedure Oriented Programming?
• Q4. What is object Oriented Programming?
• Q5. Write advantages and limitations of object oriented
programming.

More Related Content

Similar to Unit 1 introduction to c++.pptx

Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionAKR Education
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxprakashvs7
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREjatin batra
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionRai University
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionRai University
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxvishnupriyapm4
 
Advance C# Programming Part 1.pptx
Advance C# Programming Part 1.pptxAdvance C# Programming Part 1.pptx
Advance C# Programming Part 1.pptxpercivalfernandez3
 
Top 10 programming languages
Top 10 programming languagesTop 10 programming languages
Top 10 programming languagesAman Kumar
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptxPadmaN24
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingRahul Sharma
 
Advance C# Programming Part 1.pdf
Advance C# Programming Part 1.pdfAdvance C# Programming Part 1.pdf
Advance C# Programming Part 1.pdfpercivalfernandez2
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptxchouguleamruta24
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptxDivyaKS12
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingRahul Sharma
 

Similar to Unit 1 introduction to c++.pptx (20)

JAVA
JAVAJAVA
JAVA
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docx
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
 
Part 1
Part 1Part 1
Part 1
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
 
C++ chapter 1
C++ chapter 1C++ chapter 1
C++ chapter 1
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Advance C# Programming Part 1.pptx
Advance C# Programming Part 1.pptxAdvance C# Programming Part 1.pptx
Advance C# Programming Part 1.pptx
 
Top 10 programming languages
Top 10 programming languagesTop 10 programming languages
Top 10 programming languages
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oop.pptx
Oop.pptxOop.pptx
Oop.pptx
 
Advance C# Programming Part 1.pdf
Advance C# Programming Part 1.pdfAdvance C# Programming Part 1.pdf
Advance C# Programming Part 1.pdf
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 

Recently uploaded

BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentationtahreemzahra82
 
‏‏VIRUS - 123455555555555555555555555555555555555555
‏‏VIRUS -  123455555555555555555555555555555555555555‏‏VIRUS -  123455555555555555555555555555555555555555
‏‏VIRUS - 123455555555555555555555555555555555555555kikilily0909
 
Neurodevelopmental disorders according to the dsm 5 tr
Neurodevelopmental disorders according to the dsm 5 trNeurodevelopmental disorders according to the dsm 5 tr
Neurodevelopmental disorders according to the dsm 5 trssuser06f238
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...lizamodels9
 
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfBUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfWildaNurAmalia2
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsssuserddc89b
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsHajira Mahmood
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)riyaescorts54
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptx
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptxBREEDING FOR RESISTANCE TO BIOTIC STRESS.pptx
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptxPABOLU TEJASREE
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensorsonawaneprad
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxpriyankatabhane
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 

Recently uploaded (20)

BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentation
 
‏‏VIRUS - 123455555555555555555555555555555555555555
‏‏VIRUS -  123455555555555555555555555555555555555555‏‏VIRUS -  123455555555555555555555555555555555555555
‏‏VIRUS - 123455555555555555555555555555555555555555
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
Neurodevelopmental disorders according to the dsm 5 tr
Neurodevelopmental disorders according to the dsm 5 trNeurodevelopmental disorders according to the dsm 5 tr
Neurodevelopmental disorders according to the dsm 5 tr
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
 
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfBUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physics
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutions
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdf
 
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptx
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptxBREEDING FOR RESISTANCE TO BIOTIC STRESS.pptx
BREEDING FOR RESISTANCE TO BIOTIC STRESS.pptx
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensor
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 

Unit 1 introduction to c++.pptx

  • 1. S.Y.B.C.A.(Science) BCA 241-Object Oriented Programming And C++ Unit 1 Introduction to C++ Prepared by: Prof. Shashi Jadhav Modern college, Ganeshkhind,Pune.
  • 2.
  • 3. Introduction • What is Programming Language? A programming language is a type of written language that tells computers what to do. Examples are: Python, Ruby, Java, JavaScript, C, C++, and C#. Programming languages are used to write all computer programs and computer software. • Types of Computer Languages 1. Machine level 2. Assembly level 3. High level
  • 4. High level languages 1. Procedure Oriented: C, Fortran,COBOL, VB, and Pascal. 2 Object oriented: Java, C++, VB.NET, Python, and C#.NET.
  • 5. Procedure-oriented programming. • Programming in the high-level languages such as COBOL, FORTRAN, C, etc. is known as procedure-oriented programming. • Procedure-oriented programming basically contains group of instructions known as function. There are multiple functions into the program. • In below figure we have divided our program into multiple functions. • We use flowchart or algorithm to show how the program is executed from one instruction to other instruction. • It doesn’t emphasize on the data.
  • 6.
  • 7. • In a multi-function program we use global variable to communicate between two functions. • Global variable can be use by any function at any time while local variables are only used within the function. • But it creates problem in large program because we can’t determine which global variables (data) are used by which function. • Also global variables are accessed by all the function so any function can change its value at any time so all the function will be affected.
  • 8. Characteristics of procedure-oriented programming language: • It emphasis on algorithm (focus is on doing things/functions ). • Large programs are divided into smaller programs known as functions. Hence the program consist of multiple functions. • Most of the Functions share global data. • Data is not hidden, it move freely from one function to another function. • Functions change the value of data at any time from any place. (Functions transform data from one form to another.) • Hence no data security. • It uses top-down programming approach.
  • 9. Drawbacks Of POP • POP has two major drawbacks, viz. • (1) data move freely around the program and are therefore vulnerable to changes caused by any function in the program, and • (2) it does not model very well the real-world problems.
  • 10. Object-oriented programming • Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. • OOP allows decomposition of a problem into a number of entities called objects and then builds data & functions around these objects. • The data of an object can be accessed by only the function associated with that object. • However functions of one object can be accessed by functions of another object.
  • 11. Object-oriented programming • Striking features of object oriented programming are : • Emphasis is on data rather than procedure. • Programs are divided into objects. • Data structures are designed such that they characterize the objects. • Functions that operate on the data of an object are tied together in the data structure. • Data is hidden and cannot be accessed by external functions. • Objects may communicate with each other through functions. • New data and functions can be easily added whenever necessary. • Follows bottom-up approach in program design.
  • 12. BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING The basic concepts of object oriented programming include : • Objects • Classes • Data abstraction and encapsulation • Inheritance • Polymorphism • Data binding • Message passing.
  • 13. Advantages of OOP • Re-usability: Write once and use it multiple times, you can achieve this by using class. • Redundancy: This is a condition created at the place of data storage (you can say Databases)where the same piece of data is held in two separate places. So the data redundancy is one of the greatest advantages of OOP. If a user wants a similar functionality in multiple classes, he/she can go ahead by writing common class definitions for similar functionalities and inherit them. • Easy Maintenance: It is easy to maintain and modify existing code, as new objects can be created with small differences to existing ones. • Code Flexibility The flexibility is offered through the concept of Polymorphism. • Security: Using data hiding and abstraction only necessary data will be provided, thus maintains the security of data.
  • 14. Disadvantages of OOP: • Size: Object-Oriented Programs are much larger than other programs. • Effort: Object-Oriented Programs require a lot of work to create. • Speed: Object-Oriented Programs are slower than other programs, because of their size.
  • 15. Applications of object oriented programming • 1.Developing graphical user interface • 2.System Applications • 3. Object oriented database system • 4.Expert Systems • 5. Simulation and modelling softwares • 6. Artificial intelligence • 7 Compiler construction • 8 CAD/CAM software
  • 16.
  • 17. OOP Vs POP Sr. No. Key OOP POP 1 Definition OOP stands for Object Oriented Programing. POP stands for Procedural Oriented Programming. 2 Approach OOP follows bottom up approach. POP follows top down approach. 3 Division A program is divided to objects and their interactions. A program is divided into funtions and they interacts. 4 Inheritance supported Inheritance is supported. Inheritance is not supported. 5 Access control Access control is supported via access modifiers. No access modifiers are supported. 6 Data Hiding Encapsulation is used to hide data. No data hiding present. Data is globally accessible. 7 Example C++, Java C, Pascal
  • 18. Introduction to C++ It is an object oriented programming language. Evolved in 1979,by Bjarne Stroustrup at AT & T Bell laboratories. It is based on an object oriented language Simula67 and C language. C++ is an extention of C with a major addition of the class construct feature of Simula67. Initially it was called as C with classes. In 1983 it was renamed as C++(incremented version of C) C++ is a superset of C Backward compatible to C i.e. Almost all C programs are also C++ programs.
  • 19. Applications of C++ • Versatile language for handling very large programs. • Suitable for development of editors, databases, System programs. • Useful for developing good libraries which can be later used by many programmers. • C++ is used in developing browsers, operating systems, and applications, as well as in-game programming, software engineering, data structures, etc. • JVM(virtual machine of Java) and python interpreter are written in C++.
  • 20. Advantages of C++ Over Other Languages • 1. Object-Oriented C++ is an object-oriented programming language which means that the main focus is on objects and manipulations around these objects. This makes it much easier to manipulate code, unlike procedural or structured programming which requires a series of computational steps to be carried out. • 2. Speed When speed is a critical metric, C++ is the most preferred choice. The compilation and execution time of a C++ program is much faster than most general-purpose programming languages. • 3. Compiled Unlike other programming languages where no compilation is required, every C++ code has to be first compiled to a low-level language and then executed. Hence faster and more efficient to execute than interpreted languages. • 4. Rich Library Support The C++ Standard Template Library (STL) has many functions available to help write code quickly. For example, there are STLs for various containers like hash tables, maps, sets, etc. • 5. Pointer Support C++ also supports pointers which are often not available in other programming languages. • 6. Closer to Hardware C++ is closer to hardware than most general-purpose programming languages. This makes it very useful in those areas where hardware and software are closely coupled together, and low-level support is needed at the software level. Developer has more control over hardware aspects, like memory management and CPU usage.
  • 21. Features of C++ 1) Simple C++ is a simple language because it provides a structured approach (to break the problem into parts), a rich set of library functions, data types, etc. 2) Abstract Data types In C++, complex data types called Abstract Data Types (ADT) can be created using classes. 3) Portable • C++ is a portable language and programs made in it can be run on different machines.
  • 22. Features of C++ 4) Mid-level / Intermediate programming language C++ includes both low-level programming and high-level language so it is known as a mid-level and intermediate programming language. It is used to develop system applications such as kernel, driver, etc. 5) Structured programming language C++ is a structured programming language. In this we can divide the program into several parts using functions. 6) Rich Library C++ provides a lot of inbuilt functions that make the development fast. Following are the libraries used in C++ programming are: • <iostream> • <cmath> • <cstdlib> • <fstream>
  • 23. Features of C++ 7) Memory Management • C++ provides very efficient management techniques. The various memory management operators help save the memory and improve the program's efficiency. These operators allocate and deallocate memory at run time. Some common memory management operators available C++ are new, delete etc. 8) Quicker Compilation • C++ programs tend to be compact and run quickly. Hence the compilation and execution time of the C++ language is fast. 9) Pointer • C++ provides the feature of pointers. We can use pointers for memory, structures, functions, array, etc. We can directly interact with the memory by using the pointers. 10) Recursion • In C++, we can call the function within the function. It provides code reusability for every function.
  • 24. Features of C++ 11) Extensible • C++ programs can easily be extended as it is very easy to add new features into the existing program. 12) Object-Oriented • In C++, object-oriented concepts like data hiding, encapsulation, and data abstraction can easily be implemented using keyword class, private, public, and protected access specifiers. Object-oriented makes development and maintenance easier. 13) Compiler based • C++ is a compiler-based programming language, which means no C++ program can be executed without compilation. C++ compiler is easily available, and it requires very little space for storage. First, we need to compile our program using a compiler, and then we can execute our program.
  • 25. Features of C++ 14) Reusability • With the use of inheritance of functions programs written in C++ can be reused in any other program of C++. You can save program parts into library files and invoke them in your next programming projects simply by including the library files. New programs can be developed in lesser time as the existing code can be reused. It is also possible to define several functions with same name that perform different task. For Example: abs () is used to calculate the absolute value of integer, float and long integer. • 15) Redefine Existing Operators • C++ allows the programmer to redefine the meaning of existing operators such as +, -. For Example, The "+" operator can be used for adding two numbers and concatenating two strings.
  • 26. Features of C++ 16)National Standards • C++ has national standards such as ANSI. (American National Standards Institute) 17) Errors are easily detected • It is easier to maintain a C++ programs as errors can be easily located and rectified. It also provides a feature called exception handling to support error handling in your program. 18) Clarity • The keywords and library functions used in C++ resemble common English words.
  • 27. Features of C++ 19) Power and Flexibility • C++ is a powerful and flexible language because of most of the powerful flexible and modern UNIX operating system is written in C++. Many compilers and interpreters for other languages such as FORTRAN, PERL, Python, PASCAL, BASIC, LISP, etc., have been written in C++. C++ programs have been used for solving physics and engineering problems and even for animated special effects for movies. 20) Modelling real-world problems • The programs written in C++ are well suited for real-world modeling problems as close as possible to the user perspective.
  • 28. Differences between C and C++: • Definition C is a structural programming language, and it does not support classes and objects, while C++ is an object-oriented programming language that supports the concept of classes and objects. • Type of programming language C is procedure oriented programming language(POP) , while C++ is an object- oriented programming language(OOP). • Subset C++ is a superset of C programming language. C++ can run 99% of C code but C language cannot run C++ code. • Type of approach C follows the top-down approach, while C++ follows the bottom-up approach. The top-down approach breaks the main modules into tasks; these tasks are broken into sub-tasks, and so on. The bottom-up approach develops the lower level modules first and then the next level modules.
  • 29. Differences between C and C++: • Keywords C contains 32 keywords, and C++ supports 63 keywords.(81 as of C++20) • Security In C, the data can be easily manipulated by the outsiders as it does not support the encapsulation and information hiding while C++ is a very secure language, i.e., no outsiders can manipulate its data as it supports both encapsulation and data hiding. In C language, functions and data are the free entities, and in C++ language, all the functions and data are encapsulated in the form of objects. • Exception handling C does not provide direct support to the exception handling; it needs to use functions that support exception handling. C++ provides direct support to exception handling by using a try-catch block. • Input/Output functions In C, scanf and printf functions are used for input and output operations, respectively, while in C++, cin and cout are used for input and output operations, respectively.
  • 30. Differences between C and C++: • Memory allocation and de-allocation C supports calloc() and malloc() functions for the memory allocation, and free() function for the memory de-allocation. C++ supports a new operator for the memory allocation and delete operator for the memory de-allocation. • Header file C program uses <stdio.h> header file while C++ program uses <iostream.h> header file. • Namespace feature A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. C does not contain the namespace feature, while C++ supports the namespace feature that avoids the name collisions.
  • 31. Writing and executing a C++ Program Step1. Creating source code Using Vi Editor : • Open terminal • write command vi filename.cpp” for C++ (“vi filename.c” For C) • Enter “I” , to activate insert mode in vi editor . • Write your code • Enter “Esc” • Enter “:” • write “wq” ,Enter. • Now source file is created with .cpp extention
  • 32. • Step 2: • Compiling the source code: • The source file has to be converted into machine code using a compiler. For this we can use Turbo C++ or GNU C++ Compiler • Using GNU C++ Compiler gcc or g++: • for cpp code write “g++ - o filename filename.cpp” , Or write “g++ filename.cpp” • (for c code write “gcc - o filename filename.c” ,Enter) • After compiling a runnable file will be created which is called object file .(with extention .o/.obj)
  • 33. • Step3: • Linking the object code to create an Executable code- • After compilation the object file is given to linker. • This program combines the files, add necessary libraries and creates an executable file with extension .exe • Step4 • Executing the Program • Once the executable file is created, you can run it by typing its name at the DOS command prompt or through the option provided by the compiler software. • In linux /centos you can write ./filename or ./a.out and press enter.
  • 34.
  • 35.
  • 36.
  • 37. Simple C++ Program • #include <iostream> is Directives for preprocessor: • A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. • As the same name can’t be given to multiple variables, functions, classes, etc. in the same scope. • So to overcome this situation namespace is introduced. • namespace defines a scope of that entity. • std is a namespace whose members are used in the program the members of the “std” namespace are cout, cin, endl, etc. • int main() : It is Function Signatures
  • 38. #include <iostream> using namespace std; namespace sybca // first name space { void show_topper() { cout << "Raj is topper"<< endl; } } // second name space namespace tybca { void show_topper() { cout << "Radha is topper"<< endl; } } using namespace sybca; int main () { show_topper(); return 0; } •What is output ?? •Rewrite same program without using namespace
  • 39. Directives: #include <iostream> • In the first line, the file iostream is included into the current .cpp file. The hashtag (#) signals to a program called the preprocessor which reads through your source code, looking for all the lines that begin the with # symbol. The command #include tells the preprocessor “find the file iostream, read it, and place it here.” The angle brackets (<>) surrounding the file name tells the preprocessor to look in the usual places for this file. If your compiler is set up properly, all the include files are in one repository. • The file iostream is used by cout, which writes to the console. The effect of #include <iostream> is to include the file iostream into this C++ program as if you typed it in yourself.
  • 40. Function Signatures: int main() • The actual program begins with the function main(). Every C++ program needs to have a main() function because when you execute your program, main() is called automatically. • A function’s signature is important because it defines the inputs and outputs of the function. In int main(), the first part int states that the main() function returns an interger value to the operating system. This function achieves that because, at the bottom, it executes return 0. • Note: The compiler will allow you to return other data types. However, for main(), the only legal return type is int. Generally, it is the informal convention to return 0 to express that the program has ended without errors.
  • 41. The Function Body & Namespaces • All functions begin with an opening brace ({) and end with a closing brace (}). Everything in between the braces is considered to be part of that function. • cout and cin are used in C++ to handle input (such as user input from a keyboard) and output (such as printing to the console). • cout and cin objects provided by the standard library (std) • The standard library is the standard collection of objects that comes with every C++ compiler. • By using the namespace specifier std, You tell the compiler that the cout object you can use is part of the standard library
  • 42. Assignment 1 • Q1. Explain features of C++ language? • Q2.What are advantages of C++ ? • Q3. What is Procedure Oriented Programming? • Q4. What is object Oriented Programming? • Q5. Write advantages and limitations of object oriented programming.