SlideShare a Scribd company logo
1 of 47
CSC240
INTRODUCTION TO PROGRAMMING – I
Mr. Dilawar
Lecturer,
Department of Computer Science,
Jahan University
Kabul, Afghanistan.
Previous Lecture Outline
• Understanding the concept of flowcharts.
• Working with sequence, decision, repetition and case control
flowchart structures.
• Understanding algorithms.
Lecture Outline
• Introduction to C++ and other popular programming languages
• Historical development of C++
• Writing C++ program
• Structure of C++ program
Introduction to C++
• C++ is the advanced version of C language that is used for developing
computer programs.
• C++ is a powerful programming language that fully supports
• Procedural programming
• Object-oriented programming
• Data abstraction
• Generic programming
Other Popular Programming Languages
Other Popular Programming Languages
Other Popular Programming Languages
Other Popular Programming Languages
Other Popular Programming Languages
Other Popular Programming Languages
Other Popular Programming Languages
Historical Development of C++ Language
Programming Language Description
BCPL Language
Developed in 1967 by Martin Richards as a language for writing operating
systems and compilers for operating system.
B Language
Developed by Ken Thompson at Bell Laboratories. The early version of UNIX
operating system developed in 1970.
C Language
Developed by Dennish Ritche in 1972 by Bell Laboratories. It is available for
most computers and is hardware independent. Portable computer programs
can be created.
C++ Language
C++ is the extension of C developed by Bjarne Stroustrup in the early 1980s at
Bell Laboratories. It provides the capabilities of object-oriented programming.
Current versions of C++ such as Microsoft Visual C++ .NET and Borland C++ Builder.
We will follow the syntax and rules of turbo C++ version 3.0 and Borland C++ v5 for MS DOS environment.
Writing C++ Program
• C++ systems generally consist of three parts
• A program development environment
• The language
• C++ Standard Library
• C++ programs typically go through six phases
• Edit, Preprocess, Compile, Link, Load and Execute.
Writing C++ Program
Writing C++ Program
Writing C++ Program
• Phase 1 consists of editing a file with an editor program, normally
known simply as an editor.
• Type a C++ program (source code) using the editor.
• Make any necessary corrections.
• Save the program.
• C++ source code filenames often end with the .cpp, .cxx, .cc or .C extensions
(note that C is in uppercase) which indicate that a file contains C++ source
code.
Writing C++ Program
Writing C++ Program
• Linux editors: vi and emacs.
• C++ software packages for Microsoft Windows such as Microsoft
Visual C++ (microsoft.com/express) have editors integrated into the
programming environment.
• You can also use a simple text editor, such as Notepad in Windows, to
write your C++ code.
• Integrated Development Environments (IDEs)
• Provide tools that support the software-development process, including
editors for writing and editing programs and debuggers for locating logic
errors—errors that cause programs to execute incorrectly.
Writing C++ Program
• Popular IDEs
• Microsoft® Visual Studio 2012 Express Edition
• Dev C++
• NetBeans
• Eclipse
• Apple’s Xcode
• CodeLite
Writing C++ Program
• In phase 2, you give the command to compile the program.
• A preprocessor program executes automatically before the compiler’s
translation phase begins (so we call preprocessing Phase 2 and compiling
Phase 3).
• The C++ preprocessor submits commands called preprocessing directives,
which indicate that certain manipulations are to be performed on the
program before compilation.
• These manipulations usually include other text files to be compiled, and
perform various text replacements.
Writing C++ Program
Writing C++ Program
• In Phase 3, the compiler translates the C++ program into machine-
language code—also referred to as object code.
Writing C++ Program
• Phase 4 is called linking.
• The object code produced by the C++ compiler typically contains “holes” due
to some missing parts.
• A linker links the object code with the code for the missing functions to
produce an executable program.
• If the program compiles and links correctly, an executable image is produced.
Writing C++ Program
Writing C++ Program
• Phase 5 is called loading.
• Before a program can be executed, it must first be placed in memory.
• This is done by the loader, which takes the executable image from disk and
transfers it to memory.
• Additional components from shared libraries that support the program are
also loaded.
Writing C++ Program
Writing C++ Program
• Phase 6: Execution
• Finally, the computer, under the control of its CPU, executes the program
one instruction at a time.
• Some modern computer architectures can execute several instructions in
parallel.
Writing C++ Program
Writing C++ Program
• Problems That May Occur at Execution Time
• Programs might not work on the first try.
• Each of the preceding phases can fail because of various errors that we’ll
discuss throughout this course.
• If this occurred, you’d have to return to the edit phase, make the necessary
corrections and proceed through the remaining phases again to determine
that the corrections fixed the problem(s).
• There is also a standard error stream referred to as cerr. The cerr stream is
used for displaying error messages.
Writing C++ Program
Structure of C++ Program
• Preprocessor Directives
• Header Files
• main() function
• Body of main() function
• Statements
Structure of C++ Program
Structure of C++ Program
• The instructions that are given to the compiler before the beginning
of the actual program are called preprocessor directives.
• Also known as compiler directives.
• The preprocessor directives consist of instructions for the compiler.
• The compiler adds special instructions or code from these directives into the
program at the time of compilation.
• It starts with a # (HASH) or (SHARP) and the keyword include or define.
• They are used to include header files.
Structure of C++ Program
• Header files in C++ are source files that
contains definitions of library
functions/objects.
• A header is added if function/object defined
in it is to be used in the program.
• For example, the header file iostream.h has
the definitions of different built-in
input/output functions. To include the
header file into the C++ source code we
normally write:
#include<iostream>
int main()
{
…………
…………
return 0;
}
Structure of C++ Program
Structure of C++ Program
• The C++ program is typically consist
of at least one function called
main() function.
• When C++ program starts execution,
main() is the first program that is
executed.
• The keyword int to the left of main()
indicates that main() “returns” an
integer (whole number) value.
#include<iostream>
int main()
{
…………
…………
return 0;
}
Structure of C++ Program
• Each function may or may not
return a value back.
• The function contains body in which
duties of the function is placed.
#include<iostream>
int main()
{
…………
…………
return 0;
}
Structure of C++ Program
• A statement instructs the computer to
perform an action.
• Together, the quotation marks and the
characters between them are called a
string, a character string or a string
literal.
• Most C++ statements end with a
semicolon (;), also known as the
statement terminator.
• C++ is a case-sensitive language.
#include<iostream>
int main()
{
…………
…………
return 0;
}
Structure of C++ Program
• You use blank lines, space characters and tab characters (i.e., “tabs”)
to make programs easier to read.
• Together, these characters are known as white space.
• White-space characters are normally ignored by the compiler.
Structure of C++ Program
Structure of C++ Program
Structure of C++ Program
• Comments can be used for
understanding the source
code.
• Single-line (//…………..)
comment vs multi-line
(/*……..*/) comment.
//sample program
#include<iostream>
int main()
{
…………
…………
return 0;
}
Structure of C++ Program
Example
#include<iostream> //Preprocessor Directive
using namespace std;
int main(){ //main() function
cout<<“Hello world”; //statements
return 0;
}
Escape Characters
• They can be used as a separate characters or embedded in string
constant.
Summery
• Introduction to C++ and other popular programming languages
• Historical development of C++
• Writing C++ program
• Structure of C++ program
Thank You
For your Patience

More Related Content

What's hot

Introduction to C Language (By: Shujaat Abbas)
Introduction to C Language (By: Shujaat Abbas)Introduction to C Language (By: Shujaat Abbas)
Introduction to C Language (By: Shujaat Abbas)Shujaat Abbas
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design IntroductionAman Sharma
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Shivang Bajaniya
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
Turbo C
Turbo CTurbo C
Turbo Cnat236
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it worksMark John Lado, MIT
 
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof Chethan Raj C
 
Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environmentJohn Paul Espino
 
An Overview of Programming C
An Overview of Programming CAn Overview of Programming C
An Overview of Programming CNishargo Nigar
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,Hossain Md Shakhawat
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAkshay Ithape
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler designDHARANI BABU
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture NotesFellowBuddy.com
 

What's hot (20)

Introduction to C Language (By: Shujaat Abbas)
Introduction to C Language (By: Shujaat Abbas)Introduction to C Language (By: Shujaat Abbas)
Introduction to C Language (By: Shujaat Abbas)
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design Introduction
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Turbo C
Turbo CTurbo C
Turbo C
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
 
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environment
 
C programming
C programming C programming
C programming
 
An Overview of Programming C
An Overview of Programming CAn Overview of Programming C
An Overview of Programming C
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Overview of c
Overview of cOverview of c
Overview of c
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
01 c
01 c01 c
01 c
 

Viewers also liked

An Area Analysis Report of Gainesville Parks with a Focus on Springtree Park
An Area Analysis Report of Gainesville Parks with a Focus on Springtree ParkAn Area Analysis Report of Gainesville Parks with a Focus on Springtree Park
An Area Analysis Report of Gainesville Parks with a Focus on Springtree ParkDanielle Behr
 
ITCH_E.compressed
ITCH_E.compressedITCH_E.compressed
ITCH_E.compressedMike White
 
How to up Optimize Your Google Product Feed in Time for Black Friday
How to up Optimize Your Google Product Feed in Time for Black FridayHow to up Optimize Your Google Product Feed in Time for Black Friday
How to up Optimize Your Google Product Feed in Time for Black FridayTinuiti
 
Georgia Studies Jeopardy!, WWII Edition
Georgia Studies Jeopardy!, WWII EditionGeorgia Studies Jeopardy!, WWII Edition
Georgia Studies Jeopardy!, WWII EditionPatrick O'Conner
 
Byu scavenger hunt
Byu scavenger huntByu scavenger hunt
Byu scavenger huntmblangton
 
Administração Básica IBM Connections
Administração Básica IBM ConnectionsAdministração Básica IBM Connections
Administração Básica IBM ConnectionsGeorge Araujo
 
Area de tecnologia e informatica
Area de tecnologia e informatica Area de tecnologia e informatica
Area de tecnologia e informatica castanedalucy240
 
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)Juan Alejandro Alvarez Agudelo
 

Viewers also liked (16)

An Area Analysis Report of Gainesville Parks with a Focus on Springtree Park
An Area Analysis Report of Gainesville Parks with a Focus on Springtree ParkAn Area Analysis Report of Gainesville Parks with a Focus on Springtree Park
An Area Analysis Report of Gainesville Parks with a Focus on Springtree Park
 
Lfu
LfuLfu
Lfu
 
Presentación de computacion
Presentación  de computacionPresentación  de computacion
Presentación de computacion
 
ITCH_E.compressed
ITCH_E.compressedITCH_E.compressed
ITCH_E.compressed
 
How to up Optimize Your Google Product Feed in Time for Black Friday
How to up Optimize Your Google Product Feed in Time for Black FridayHow to up Optimize Your Google Product Feed in Time for Black Friday
How to up Optimize Your Google Product Feed in Time for Black Friday
 
Powerp2
Powerp2Powerp2
Powerp2
 
Georgia Studies Jeopardy!, WWII Edition
Georgia Studies Jeopardy!, WWII EditionGeorgia Studies Jeopardy!, WWII Edition
Georgia Studies Jeopardy!, WWII Edition
 
dean resume (1)
dean resume (1)dean resume (1)
dean resume (1)
 
Csc240 -lecture_2
Csc240  -lecture_2Csc240  -lecture_2
Csc240 -lecture_2
 
Project Part 2
Project Part 2Project Part 2
Project Part 2
 
IJRET20140304067
IJRET20140304067IJRET20140304067
IJRET20140304067
 
Byu scavenger hunt
Byu scavenger huntByu scavenger hunt
Byu scavenger hunt
 
Administração Básica IBM Connections
Administração Básica IBM ConnectionsAdministração Básica IBM Connections
Administração Básica IBM Connections
 
Area de tecnologia e informatica
Area de tecnologia e informatica Area de tecnologia e informatica
Area de tecnologia e informatica
 
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)
Un breve resumen de álgebra lineal - Juan Álvarez (incompleto)
 
Statistical lechure
Statistical lechureStatistical lechure
Statistical lechure
 

Similar to Csc240 -lecture_3

Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxCoolGamer16
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itPushkarNiroula1
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingRokonuzzaman Rony
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++Vaibhav Khanna
 
Understanding how C program works
Understanding how C program worksUnderstanding how C program works
Understanding how C program worksMindBridgeTech
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translatorsimtiazalijoono
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge imtiazalijoono
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 

Similar to Csc240 -lecture_3 (20)

Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
C_Intro.ppt
C_Intro.pptC_Intro.ppt
C_Intro.ppt
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Understanding how C program works
Understanding how C program worksUnderstanding how C program works
Understanding how C program works
 
C++ l 1
C++ l 1C++ l 1
C++ l 1
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translators
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
Learn C Language
Learn C LanguageLearn C Language
Learn C Language
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 

More from Ainuddin Yousufzai

More from Ainuddin Yousufzai (15)

Chapter04 ip addressing networking
Chapter04 ip addressing networkingChapter04 ip addressing networking
Chapter04 ip addressing networking
 
Chapter 02 topology networking
Chapter 02  topology networkingChapter 02  topology networking
Chapter 02 topology networking
 
Chapter 01 networking
Chapter 01 networkingChapter 01 networking
Chapter 01 networking
 
Chapter08 internet &amp; multimedia (b)
Chapter08   internet &amp; multimedia (b)Chapter08   internet &amp; multimedia (b)
Chapter08 internet &amp; multimedia (b)
 
Chapter08 internet &amp; multimedia (a)
Chapter08   internet &amp; multimedia (a)Chapter08   internet &amp; multimedia (a)
Chapter08 internet &amp; multimedia (a)
 
Chapter07 io devices
Chapter07   io devicesChapter07   io devices
Chapter07 io devices
 
Chapter06 computer software
Chapter06   computer softwareChapter06   computer software
Chapter06 computer software
 
Chapter05 secondary storage
Chapter05   secondary storageChapter05   secondary storage
Chapter05 secondary storage
 
Chapter04 processor and memory
Chapter04   processor and memoryChapter04   processor and memory
Chapter04 processor and memory
 
Chapter03 number system
Chapter03   number systemChapter03   number system
Chapter03 number system
 
Chapter02 basic computer organization
Chapter02   basic computer organizationChapter02   basic computer organization
Chapter02 basic computer organization
 
Chapter01 introduction to computer
Chapter01   introduction to computerChapter01   introduction to computer
Chapter01 introduction to computer
 
Csc240 -lecture_5
Csc240  -lecture_5Csc240  -lecture_5
Csc240 -lecture_5
 
Csc240 -lecture_4
Csc240  -lecture_4Csc240  -lecture_4
Csc240 -lecture_4
 
Csc240 lecture 1
Csc240   lecture 1Csc240   lecture 1
Csc240 lecture 1
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Csc240 -lecture_3

  • 1. CSC240 INTRODUCTION TO PROGRAMMING – I Mr. Dilawar Lecturer, Department of Computer Science, Jahan University Kabul, Afghanistan.
  • 2. Previous Lecture Outline • Understanding the concept of flowcharts. • Working with sequence, decision, repetition and case control flowchart structures. • Understanding algorithms.
  • 3. Lecture Outline • Introduction to C++ and other popular programming languages • Historical development of C++ • Writing C++ program • Structure of C++ program
  • 4. Introduction to C++ • C++ is the advanced version of C language that is used for developing computer programs. • C++ is a powerful programming language that fully supports • Procedural programming • Object-oriented programming • Data abstraction • Generic programming
  • 12. Historical Development of C++ Language Programming Language Description BCPL Language Developed in 1967 by Martin Richards as a language for writing operating systems and compilers for operating system. B Language Developed by Ken Thompson at Bell Laboratories. The early version of UNIX operating system developed in 1970. C Language Developed by Dennish Ritche in 1972 by Bell Laboratories. It is available for most computers and is hardware independent. Portable computer programs can be created. C++ Language C++ is the extension of C developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories. It provides the capabilities of object-oriented programming. Current versions of C++ such as Microsoft Visual C++ .NET and Borland C++ Builder. We will follow the syntax and rules of turbo C++ version 3.0 and Borland C++ v5 for MS DOS environment.
  • 13. Writing C++ Program • C++ systems generally consist of three parts • A program development environment • The language • C++ Standard Library • C++ programs typically go through six phases • Edit, Preprocess, Compile, Link, Load and Execute.
  • 16. Writing C++ Program • Phase 1 consists of editing a file with an editor program, normally known simply as an editor. • Type a C++ program (source code) using the editor. • Make any necessary corrections. • Save the program. • C++ source code filenames often end with the .cpp, .cxx, .cc or .C extensions (note that C is in uppercase) which indicate that a file contains C++ source code.
  • 18. Writing C++ Program • Linux editors: vi and emacs. • C++ software packages for Microsoft Windows such as Microsoft Visual C++ (microsoft.com/express) have editors integrated into the programming environment. • You can also use a simple text editor, such as Notepad in Windows, to write your C++ code. • Integrated Development Environments (IDEs) • Provide tools that support the software-development process, including editors for writing and editing programs and debuggers for locating logic errors—errors that cause programs to execute incorrectly.
  • 19. Writing C++ Program • Popular IDEs • Microsoft® Visual Studio 2012 Express Edition • Dev C++ • NetBeans • Eclipse • Apple’s Xcode • CodeLite
  • 20. Writing C++ Program • In phase 2, you give the command to compile the program. • A preprocessor program executes automatically before the compiler’s translation phase begins (so we call preprocessing Phase 2 and compiling Phase 3). • The C++ preprocessor submits commands called preprocessing directives, which indicate that certain manipulations are to be performed on the program before compilation. • These manipulations usually include other text files to be compiled, and perform various text replacements.
  • 22. Writing C++ Program • In Phase 3, the compiler translates the C++ program into machine- language code—also referred to as object code.
  • 23. Writing C++ Program • Phase 4 is called linking. • The object code produced by the C++ compiler typically contains “holes” due to some missing parts. • A linker links the object code with the code for the missing functions to produce an executable program. • If the program compiles and links correctly, an executable image is produced.
  • 25. Writing C++ Program • Phase 5 is called loading. • Before a program can be executed, it must first be placed in memory. • This is done by the loader, which takes the executable image from disk and transfers it to memory. • Additional components from shared libraries that support the program are also loaded.
  • 27. Writing C++ Program • Phase 6: Execution • Finally, the computer, under the control of its CPU, executes the program one instruction at a time. • Some modern computer architectures can execute several instructions in parallel.
  • 29. Writing C++ Program • Problems That May Occur at Execution Time • Programs might not work on the first try. • Each of the preceding phases can fail because of various errors that we’ll discuss throughout this course. • If this occurred, you’d have to return to the edit phase, make the necessary corrections and proceed through the remaining phases again to determine that the corrections fixed the problem(s). • There is also a standard error stream referred to as cerr. The cerr stream is used for displaying error messages.
  • 31. Structure of C++ Program • Preprocessor Directives • Header Files • main() function • Body of main() function • Statements
  • 32. Structure of C++ Program
  • 33. Structure of C++ Program • The instructions that are given to the compiler before the beginning of the actual program are called preprocessor directives. • Also known as compiler directives. • The preprocessor directives consist of instructions for the compiler. • The compiler adds special instructions or code from these directives into the program at the time of compilation. • It starts with a # (HASH) or (SHARP) and the keyword include or define. • They are used to include header files.
  • 34. Structure of C++ Program • Header files in C++ are source files that contains definitions of library functions/objects. • A header is added if function/object defined in it is to be used in the program. • For example, the header file iostream.h has the definitions of different built-in input/output functions. To include the header file into the C++ source code we normally write: #include<iostream> int main() { ………… ………… return 0; }
  • 35. Structure of C++ Program
  • 36. Structure of C++ Program • The C++ program is typically consist of at least one function called main() function. • When C++ program starts execution, main() is the first program that is executed. • The keyword int to the left of main() indicates that main() “returns” an integer (whole number) value. #include<iostream> int main() { ………… ………… return 0; }
  • 37. Structure of C++ Program • Each function may or may not return a value back. • The function contains body in which duties of the function is placed. #include<iostream> int main() { ………… ………… return 0; }
  • 38. Structure of C++ Program • A statement instructs the computer to perform an action. • Together, the quotation marks and the characters between them are called a string, a character string or a string literal. • Most C++ statements end with a semicolon (;), also known as the statement terminator. • C++ is a case-sensitive language. #include<iostream> int main() { ………… ………… return 0; }
  • 39. Structure of C++ Program • You use blank lines, space characters and tab characters (i.e., “tabs”) to make programs easier to read. • Together, these characters are known as white space. • White-space characters are normally ignored by the compiler.
  • 40. Structure of C++ Program
  • 41. Structure of C++ Program
  • 42. Structure of C++ Program • Comments can be used for understanding the source code. • Single-line (//…………..) comment vs multi-line (/*……..*/) comment. //sample program #include<iostream> int main() { ………… ………… return 0; }
  • 43. Structure of C++ Program
  • 44. Example #include<iostream> //Preprocessor Directive using namespace std; int main(){ //main() function cout<<“Hello world”; //statements return 0; }
  • 45. Escape Characters • They can be used as a separate characters or embedded in string constant.
  • 46. Summery • Introduction to C++ and other popular programming languages • Historical development of C++ • Writing C++ program • Structure of C++ program
  • 47. Thank You For your Patience

Editor's Notes

  1. Data abstraction means determining the essential characteristics of an object. Abstraction is one of the basic principles of object-oriented design, which allows you for creating user-defined data types, known as objects. Object oriented programming abbreviated as OOP is a programming approach that supports object technology. It allows pieces of software to be reused and interchanged between programs. Major concepts used in OOP are encapsulation, inheritance, and polymorphism. Generic programming means that you are not writing source code that is compiled, but that you write templates of source codes that the compiler in the process of compilation transforms into source codes. Generic programming is about simplifying software components so that they can be easily reused in a wide variety of situations.
  2. C++ programs consist of pieces called classes and functions. Most C++ programmers take advantage of the rich collections of classes and functions in the C++ Standard Library. Two parts to learning the C++ “world.” The C++ language itself, and How to use the classes and functions in the C++ Standard Library. Many special-purpose class libraries are supplied by independent software vendors.
  3. C++ programs typically contain references to functions and data defined elsewhere, such as in the standard libraries or in the private libraries of groups of programmers working on a particular project.
  4. Programs input and output data. Input cin and output through cout.
  5. logic errors—errors that cause programs to execute incorrectly.
  6. A keyword is a word in code that is reserved by C++ for a specific use.
  7. White-space characters in strings are not ignored by the compiler.
  8. << stream insertion or put to operator A namespace is designed to overcome this difficulty and is used as additional information to differentiate similar functions, classes, variables etc. with the same name available in different libraries. Using namespace, you can define the context in which names are defined. In essence, a namespace defines a scope.