SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Programming Language
A programming language is said to use
static typing when type checking is
performed during compile-time as
opposed to run-time.
OOP
Object-Oriented Programming
• C++ fully supports object-oriented
programming, including the four pillars of
object-oriented development:
• Encapsulation
• Data hiding
• Inheritance
• Polymorphism
Encapsulation
• Encapsulation is an Object
Oriented Programming concept that binds
together the data and functions that
manipulate the data, and that keeps both safe
from outside interference and misuse.
Dataencapsulation led to the
important OOP concept of data hiding.
Data hiding
• Data hiding, also known as
information hiding or data encapsulation in
computer science, is a software development
technique used inobject-
oriented programming. It is mainly used
to hide internal object details, i.e. the design
decisions in a computer program that are
most likely to change.
inheritance
• In object-
oriented programming, inheritance enables
new objects to take on the properties of
existing objects. A class that is used as the
basis for inheritance is called a superclass or
base class. A class thatinherits from a
superclass is called a subclass or derived class.
Polymorphism
• Polymorphism refers to a programming
language'sability to process objects differently
depending on their data type orclass.
Diagram
How (OOP) languages are designed to
overcome these problems.
• The basic unit of OOP is a class, which encapsulates
both the static attributes and dynamic behaviorswithin
a "box", and specifies the public interface for using
these boxes
• OOP languages permit higher level of abstraction for
solving real-life problems. The traditional procedural
language (such as C and Pascal) forces you to think in
terms of the structure of the computer (e.g. memory
bits and bytes, array, decision, loop) rather than
thinking in terms of the problem you are trying to
solve.
Benefits of OOP
• Ease in software design as you could think in
the problem space rather than the machine's
bits and bytes. You are dealing with high-level
concepts and abstractions
• Ease in software maintenance: object-
oriented software are easier to understand,
therefore easier to test, debug, and maintain.
Classes & Instances
• A class can be visualized as a three-compartment box, as
illustrated:
• Classname (or identifier): identifies the class.
• Data Members or Variables (or attributes, states, fields):
contains the static attributes of the class.
• Member Functions (or methods, behaviors, operations):
contains the dynamic operations of the class.
• In other words, a class encapsulates the static attributes
(data) and dynamic behaviors (operations that operate on
the data) in a box.
• Class Members: The data members and member
functions are collectively called class members.
Standard Libraries
Standard C++ consists of three important parts:
• The core language giving all the building
blocks including variables, data types and
literals, etc.
• The C++ Standard Library giving a rich set of
functions manipulating files, strings, etc.
• The Standard Template Library (STL) giving a
rich set of methods manipulating data
structures, etc.
ANSI Standard
• The ANSI standard is an attempt to ensure
that C++ is portable -- that code you write for
Microsoft's compiler will compile without
errors, using a compiler on a Mac, UNIX, a
Windows box, or an Alpha.
• The ANSI standard has been stable for a while,
and all the major C++ compiler manufacturers
support the ANSI standard.
Text Editor:
• This will be used to type your program. Examples
of few editors include Windows Notepad, OS Edit
command, Brief, Epsilon, EMACS, and vim or vi.
• Name and version of text editor can vary on
different operating systems. For example,
Notepad will be used on Windows and vim or vi
can be used on windows as well as Linux, or
UNIX.
• The files you create with your editor are called
source files and for C++ they typically are named
with the extension .cpp, .cp, or .c.
Translator
• Compiler
• Interpreter
Behavior of the Language
• Object - Objects have states and behaviors. Example: A dog
has states - color, name, breed as well as behaviors -
wagging, barking, eating. An object is an instance of a class.
• Class - A class can be defined as a template/blueprint that
describes the behaviors/states that object of its type
support.
• Methods - A method is basically a behavior. A class can
contain many methods. It is in methods where the logics
are written, data is manipulated and all the actions are
executed.
• Instant Variables - Each object has its unique set of instant
variables. An object's state is created by the values
assigned to these instant variables.
C++ Program Structure
#include <iostream>
using namespace std;
// main() is where program execution begins.
int main()
{
cout << "Hello World";
// prints Hello World
return 0;
}
Expalination
• The C++ language defines several headers, which contain
information that is either necessary or useful to your program. For
this program, the header <iostream> is needed.
• The line using namespace std; tells the compiler to use the std
namespace. Namespaces are a relatively recent addition to C++.
• The next line // main() is where program execution begins. is a
single-line comment available in C++. Single-line comments begin
with // and stop at the end of the line.
• The line int main() is the main function where program execution
begins.
• The next line cout << "This is my first C++ program.";causes the
message "This is my first C++ program" to be displayed on the
screen.
• The next line return 0; terminates main( )function and causes it to
return the value 0 to the calling process.
C++ Data Types
• While doing programming in any programming
language, you need to use various variables to
store various information. Variables are nothing
but reserved memory locations to store values.
This means that when you create a variable you
reserve some space in memory.
• You may like to store information of various data
types like character, wide character, integer,
floating point, double floating point, boolean .
seven basic C++ data types
Type Keyword
• Boolean bool
• Character char
• Integer int
• Floating point float
• Double floating point double
• Valueless void
• Wide character wchar_t
Loop
• Programming languages provide various
control structures that allow for more
complicated execution paths.
• A loop statement allows us to execute a
statement or group of statements multiple
times and following is the general from of a
loop statement in most of the programming
languages:
Structure of Loop
Types of Loop
• Loop Types Description
• while loop
Repeats a statement or group of statements while a given condition
is true. It tests the condition before executing the loop body.
• for loop
Execute a sequence of statements multiple times and abbreviates
the code that manages the loop variable.
• do...while loop
Like a while statement, except that it tests the condition at the end
of the loop body
• nested loops
You can use one or more loop inside any another while, for or
do..while loop.
Loop Control Statements:
• Loop control statements change execution
from its normal sequence. When execution
leaves a scope, all automatic objects that were
created in that scope are destroyed.
control statements
• break statement
• Terminates the loop or switch statement and transfers
execution to the statement immediately following the
loop or switch.
• continue statement
• Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
• goto statement
• Transfers control to the labeled statement. Though it is
not advised to use goto statement in your program.
For Loop
• The “for loop” loops from one number to
another number and increases by a specified
value each time.
The “for loop” uses the following structure:
for (Start value; end condition; increase value)
statement(s);
Example
#include<iostream>
using namespace std;
int main()
{
int i;
for (i = 0; i < 10; i++)
{
cout << “My Name" << "n";
cout << “Pakistan" << "n";
}
return 0;
}
While loop
• The while loop can be used if you don’t know
how many times a loop must run.
Examples
#include<iostream>
using namespace std;
int main()
{
int counter, howmuch;
cin >> howmuch;
counter = 0;
while ( counter < howmuch)
{
counter++;
cout << counter << 'n';
}
return 0;
}
do while loop
The “do while loop” is almost the same as the
while loop. The “do while loop” has the
following form:
Example
#include <iostream>
using namespace std;
int main()
{
int counter, howmuch;
cin >> howmuch;
counter = 0;
do
{
counter++;
cout << counter << 'n';
}
while ( counter < howmuch);
return 0;
}
Break and continue
• To exit a loop you can use the break statement
at any time. This can be very useful if you
want to stop running a loop because a
condition has been met other than the loop
end condition
Example
#include <iostream>
using namespace std;
int main()
{
int i;
i = 0;
while ( i < 20 )
{ i++;
cout << "Hellon";
if ( i == 10)
break;
}
return 0;
}
Example
#include <iostream>
using namespace std;
int main()
{
int i;
i = 0;
while ( i < 20 )
{
i++;
continue;
cout << "Hellon";
if ( i == 10)
break;
}
return 0;
}

Weitere ähnliche Inhalte

Was ist angesagt?

Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
Jussi Pohjolainen
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
Programming languages
Programming languagesProgramming languages
Programming languages
vito_carleone
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
salmankhan570
 

Was ist angesagt? (20)

introduction to programming languages
introduction to programming languagesintroduction to programming languages
introduction to programming languages
 
Dart PPT.pptx
Dart PPT.pptxDart PPT.pptx
Dart PPT.pptx
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
pdf c programming language.pdf
pdf c programming language.pdfpdf c programming language.pdf
pdf c programming language.pdf
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Swift Introduction
Swift IntroductionSwift Introduction
Swift Introduction
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Introduction Programming Languages
Introduction Programming LanguagesIntroduction Programming Languages
Introduction Programming Languages
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
 
Why programming is important
Why programming is importantWhy programming is important
Why programming is important
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
 
Generations of programming_language.kum_ari11-1-1-1
Generations of programming_language.kum_ari11-1-1-1Generations of programming_language.kum_ari11-1-1-1
Generations of programming_language.kum_ari11-1-1-1
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
 

Andere mochten auch

Functions Of Operating Systems
Functions Of Operating SystemsFunctions Of Operating Systems
Functions Of Operating Systems
Akshay Kurup
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its function
Nikhi Jain
 
1. STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
1.	STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...1.	STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
1. STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
AELC
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
Vaibhav Bajaj
 

Andere mochten auch (9)

User Interface
User InterfaceUser Interface
User Interface
 
ICT, Importance of programming and programming languages
ICT, Importance of programming and programming languagesICT, Importance of programming and programming languages
ICT, Importance of programming and programming languages
 
Unit 5
Unit 5Unit 5
Unit 5
 
Functions Of Operating Systems
Functions Of Operating SystemsFunctions Of Operating Systems
Functions Of Operating Systems
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its function
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
1. STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
1.	STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...1.	STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
1. STUDY ON QUALITY ASSURANCE AND QUALITY CONTROL MANAGEMENT SYSTEM IN 20 STO...
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Presentation on operating system
 Presentation on operating system Presentation on operating system
Presentation on operating system
 

Ähnlich wie Programming Language

Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptx
JEEVANANTHAMG6
 

Ähnlich wie Programming Language (20)

Lecture02
Lecture02Lecture02
Lecture02
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
C++ first s lide
C++ first s lideC++ first s lide
C++ first s lide
 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
cs8251 unit 1 ppt
cs8251 unit 1 pptcs8251 unit 1 ppt
cs8251 unit 1 ppt
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++
 
73d32 session1 c++
73d32 session1 c++73d32 session1 c++
73d32 session1 c++
 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Java introduction
Java introductionJava introduction
Java introduction
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptx
 
C++ programming Assignment Help
C++ programming Assignment HelpC++ programming Assignment Help
C++ programming Assignment Help
 

Programming Language

  • 1. Programming Language A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time.
  • 2. OOP Object-Oriented Programming • C++ fully supports object-oriented programming, including the four pillars of object-oriented development: • Encapsulation • Data hiding • Inheritance • Polymorphism
  • 3. Encapsulation • Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. Dataencapsulation led to the important OOP concept of data hiding.
  • 4. Data hiding • Data hiding, also known as information hiding or data encapsulation in computer science, is a software development technique used inobject- oriented programming. It is mainly used to hide internal object details, i.e. the design decisions in a computer program that are most likely to change.
  • 5. inheritance • In object- oriented programming, inheritance enables new objects to take on the properties of existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A class thatinherits from a superclass is called a subclass or derived class.
  • 6. Polymorphism • Polymorphism refers to a programming language'sability to process objects differently depending on their data type orclass.
  • 8. How (OOP) languages are designed to overcome these problems. • The basic unit of OOP is a class, which encapsulates both the static attributes and dynamic behaviorswithin a "box", and specifies the public interface for using these boxes • OOP languages permit higher level of abstraction for solving real-life problems. The traditional procedural language (such as C and Pascal) forces you to think in terms of the structure of the computer (e.g. memory bits and bytes, array, decision, loop) rather than thinking in terms of the problem you are trying to solve.
  • 9. Benefits of OOP • Ease in software design as you could think in the problem space rather than the machine's bits and bytes. You are dealing with high-level concepts and abstractions • Ease in software maintenance: object- oriented software are easier to understand, therefore easier to test, debug, and maintain.
  • 11. • A class can be visualized as a three-compartment box, as illustrated: • Classname (or identifier): identifies the class. • Data Members or Variables (or attributes, states, fields): contains the static attributes of the class. • Member Functions (or methods, behaviors, operations): contains the dynamic operations of the class. • In other words, a class encapsulates the static attributes (data) and dynamic behaviors (operations that operate on the data) in a box. • Class Members: The data members and member functions are collectively called class members.
  • 12. Standard Libraries Standard C++ consists of three important parts: • The core language giving all the building blocks including variables, data types and literals, etc. • The C++ Standard Library giving a rich set of functions manipulating files, strings, etc. • The Standard Template Library (STL) giving a rich set of methods manipulating data structures, etc.
  • 13. ANSI Standard • The ANSI standard is an attempt to ensure that C++ is portable -- that code you write for Microsoft's compiler will compile without errors, using a compiler on a Mac, UNIX, a Windows box, or an Alpha. • The ANSI standard has been stable for a while, and all the major C++ compiler manufacturers support the ANSI standard.
  • 14. Text Editor: • This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi. • Name and version of text editor can vary on different operating systems. For example, Notepad will be used on Windows and vim or vi can be used on windows as well as Linux, or UNIX. • The files you create with your editor are called source files and for C++ they typically are named with the extension .cpp, .cp, or .c.
  • 16. Behavior of the Language • Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating. An object is an instance of a class. • Class - A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. • Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. • Instant Variables - Each object has its unique set of instant variables. An object's state is created by the values assigned to these instant variables.
  • 17. C++ Program Structure #include <iostream> using namespace std; // main() is where program execution begins. int main() { cout << "Hello World"; // prints Hello World return 0; }
  • 18. Expalination • The C++ language defines several headers, which contain information that is either necessary or useful to your program. For this program, the header <iostream> is needed. • The line using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++. • The next line // main() is where program execution begins. is a single-line comment available in C++. Single-line comments begin with // and stop at the end of the line. • The line int main() is the main function where program execution begins. • The next line cout << "This is my first C++ program.";causes the message "This is my first C++ program" to be displayed on the screen. • The next line return 0; terminates main( )function and causes it to return the value 0 to the calling process.
  • 19. C++ Data Types • While doing programming in any programming language, you need to use various variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. • You may like to store information of various data types like character, wide character, integer, floating point, double floating point, boolean .
  • 20. seven basic C++ data types Type Keyword • Boolean bool • Character char • Integer int • Floating point float • Double floating point double • Valueless void • Wide character wchar_t
  • 21. Loop • Programming languages provide various control structures that allow for more complicated execution paths. • A loop statement allows us to execute a statement or group of statements multiple times and following is the general from of a loop statement in most of the programming languages:
  • 23. Types of Loop • Loop Types Description • while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. • for loop Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. • do...while loop Like a while statement, except that it tests the condition at the end of the loop body • nested loops You can use one or more loop inside any another while, for or do..while loop.
  • 24. Loop Control Statements: • Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
  • 25. control statements • break statement • Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch. • continue statement • Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. • goto statement • Transfers control to the labeled statement. Though it is not advised to use goto statement in your program.
  • 26. For Loop • The “for loop” loops from one number to another number and increases by a specified value each time. The “for loop” uses the following structure: for (Start value; end condition; increase value) statement(s);
  • 27. Example #include<iostream> using namespace std; int main() { int i; for (i = 0; i < 10; i++) { cout << “My Name" << "n"; cout << “Pakistan" << "n"; } return 0; }
  • 28. While loop • The while loop can be used if you don’t know how many times a loop must run.
  • 29. Examples #include<iostream> using namespace std; int main() { int counter, howmuch; cin >> howmuch; counter = 0; while ( counter < howmuch) { counter++; cout << counter << 'n'; } return 0; }
  • 30. do while loop The “do while loop” is almost the same as the while loop. The “do while loop” has the following form:
  • 31. Example #include <iostream> using namespace std; int main() { int counter, howmuch; cin >> howmuch; counter = 0; do { counter++; cout << counter << 'n'; } while ( counter < howmuch); return 0; }
  • 32. Break and continue • To exit a loop you can use the break statement at any time. This can be very useful if you want to stop running a loop because a condition has been met other than the loop end condition
  • 33. Example #include <iostream> using namespace std; int main() { int i; i = 0; while ( i < 20 ) { i++; cout << "Hellon"; if ( i == 10) break; } return 0; }
  • 34. Example #include <iostream> using namespace std; int main() { int i; i = 0; while ( i < 20 ) { i++; continue; cout << "Hellon"; if ( i == 10) break; } return 0; }