SlideShare a Scribd company logo
1 of 38
Tutor: Bilal Janjooa Assistant Professor UOL
MS Telecom. Eng. From University of Sunderland UK
Bilal Janjooa bilal.janjooa@yahoo.co.uk 1
Bilal Janjooa bilal.janjooa@yahoo.co.uk 2
3
Machine Languages, Assembly
Languages, and High-level Languages
 Three types of computer languages
1. Machine language
 Only language computer directly understands
 “Natural language” of computer
 Defined by hardware design
 Machine-dependent
 Generally consist of strings of numbers
 Instruct computers to perform elementary operations
 One at a time
 Example:
+1300042774
+1400593419
+1200274027
Bilal Janjooa bilal.janjooa@yahoo.co.uk
4
Machine Languages, Assembly
Languages, and High-level Languages
 Three types of computer languages
2. Assembly language
 English-like abbreviations representing elementary
computer operations
 Clearer to humans
 Incomprehensible to computers
 Translator programs (assemblers)
 Convert to machine language
 Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Bilal Janjooa bilal.janjooa@yahoo.co.uk
5
Machine Languages, Assembly
Languages, and High-level Languages
 Three types of computer languages
3. High-level languages
 Similar to everyday English, use common mathematical
notations
 Single statements accomplish substantial tasks
 Assembly language requires many instructions to
accomplish simple tasks
 Translator programs (compilers)
 Convert to machine language
 Interpreter programs
 Directly execute high-level language programs
 Example:
grossPay = basePay + overTimePay
Bilal Janjooa bilal.janjooa@yahoo.co.uk
Introduction
to C++
Bilal Janjooa bilal.janjooa@yahoo.co.uk 6
History of C and C++
 History of C
 Evolved from two other
programming languages
 BCPL and B
 “Typeless” languages
 Dennis Ritchie (Bell
Laboratories)
 Added data typing, other features
 Development language of
UNIX
 Hardware independent
 Portable programs
 1989: ANSI standard
 1990: ANSI and ISO standard
published
 ANSI/ISO 9899: 1990
7Bilal Janjooa bilal.janjooa@yahoo.co.uk
History of C and C++
 History of C++
 Extension of C
 Early 1980s: Bjarne Stroustrup
(Bell Laboratories)
 “Spruces up” C
 Provides capabilities for
object-oriented programming
 Objects: reusable software
components
 Model items in real world
 Object-oriented programs
 Easy to understand, correct and
modify
 Hybrid language
 C-like style
 Object-oriented style
 Both
8Bilal Janjooa bilal.janjooa@yahoo.co.uk
Source code, Object code and
Compiler.
 Source code is the version of a computer program as it
is originally written (i.e., typed into a computer) by a
human in a programming language.
 Object code is the output of a compiler after it
processes source code.
 A compiler is a specialized program that converts
source code into object code.
Bilal Janjooa bilal.janjooa@yahoo.co.uk 9
10
Phases of C++ Programs:
1. Edit
2. Preprocess
3. Compile
4. Link
5. Load
6. Execute
Loader
Primary
Memory
Program is created in
the editor and stored
on disk.
Preprocessor program
processes the code.
Loader puts program
in memory.
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
Compiler
Compiler creates
object code and stores
it on disk.
Linker links the object
code with the libraries,
creates a.out and
stores it on disk
Editor
Preprocessor
Linker
CPU
Primary
Memory
.
.
.
.
.
.
.
.
.
.
.
.
Disk
Disk
Disk
Disk
Disk
Bilal Janjooa bilal.janjooa@yahoo.co.uk
Flow of C++ Program
 Compile:Translate a program
from source code to assembly code.
 Assembler:Translate a program
from assembly code to object code
(sometimes these two steps are
combined and called compiling).
 Link:Pull together all of the functions
needed for the program (both user
defined objects and system libraries)
and arrange that locations of functions
and variables are known. This step
creates the executable.
 Load:Move the executable into
computer memory.
 Execute:Run the program
Bilal Janjooa bilal.janjooa@yahoo.co.uk 11
#include <iostream.h>
main ( )
{
cout << “ Welcome to University of Lahore “;
}
Bilal Janjooa bilal.janjooa@yahoo.co.uk 12
Pre-processor directive
 # include <iostream.h>
 #include: This is a pre-processor directive. It is not part
of our program; it is an instruction to the compiler. It
tells the C compiler to include the contents of a file, in
this case the system file iostream.h.
 The sign # is known as HASH
Bilal Janjooa bilal.janjooa@yahoo.co.uk 13
Variable
During
programming we
need to store data.
This data is stored in
variables. Variables
are locations in
memory for storing
data. The memory is
divided into blocks.
X
Bilal Janjooa bilal.janjooa@yahoo.co.uk 14
Variable
Variable starts with
1. Character
2. Underscore _ (Not Recommended)
Bilal Janjooa bilal.janjooa@yahoo.co.uk 15
Variable
 Small post box
X
Bilal Janjooa bilal.janjooa@yahoo.co.uk 16
Variable
Variable is the name of a location in
the memory
e.g. x= 2;
Bilal Janjooa bilal.janjooa@yahoo.co.uk 17
Variable
In a program a variable has:
1. Name
2. Type
3. Size
4. Value
Bilal Janjooa bilal.janjooa@yahoo.co.uk 18
Assignment Operator
=
x = 2
X
2
Bilal Janjooa bilal.janjooa@yahoo.co.uk 19
X = 10 ;
X = 30 ;
X 10
X 30
Bilal Janjooa bilal.janjooa@yahoo.co.uk 20
X = X + 1;
10 + 1
=
X
11
Bilal Janjooa bilal.janjooa@yahoo.co.uk 21
Data type
 int i ; ->
Declaration line
i
Bilal Janjooa bilal.janjooa@yahoo.co.uk 22
Bilal Janjooa bilal.janjooa@yahoo.co.uk 23
#include <iostream.h>
main ( )
{
int x ;
int y ;
int z ;
x = 10 ;
y = 20 ;
z = x + y ;
cout << " x = " ;
cout << x ;
cout << " y = " ;
cout << y ;
cout << " z =x + y = " ;
cout << z ;
}
int x, y, z ;
int x; int y; int z ;
Bilal Janjooa bilal.janjooa@yahoo.co.uk 24
Data Types
1. int
2. short
3. long
4. float
5. double
6. char
Data Types
int
The data type int is used to store
whole numbers (integers). The
integer type has a space of 4 bytes (32
bits for windows operating system) in
memory. And it is mentioned as ‘int’
which is a reserved word of C, so we
can not use it as a variable name.
Bilal Janjooa bilal.janjooa@yahoo.co.uk 26
Data Types
Short
We noted that the integer occupies four
bytes in memory. So if we have to store a
small integer like 5, 10 or 20 four bytes
would be used. The C provides another data
type for storing small whole numbers
which is called short. The size of short is
two bytes and it can store numbers in range
of -32768 to 32767. So if we are going to use a
variable for which we know that it will not
increase from 32767
Bilal Janjooa bilal.janjooa@yahoo.co.uk 27
Data Types
Long
we have a very large whole number that
can not be stored in an int then we use
the data type long provided by C. So
when we are going to deal with very big
whole numbers in our program, we use
long data type. We use it in program as:
long x = 300500200;
Bilal Janjooa bilal.janjooa@yahoo.co.uk 28
Real Numbers
 The C language provides two data types to deal with
real numbers (numbers with decimal points e.g. 1.35,
735.251). The real numbers are also known as floating
point numbers.
 float
 double
Bilal Janjooa bilal.janjooa@yahoo.co.uk 29
Data Types
float
To store real numbers, float data type
is used. The float data type uses four
bytes to store a real number.
Bilal Janjooa bilal.janjooa@yahoo.co.uk 30
Data Types
double
If we need to store a large real
number which cannot be store in
four bytes, then we use double data
type. Normally the size of double is
twice the size of float. In program we
use it as:
double x = 345624.769123;
Bilal Janjooa bilal.janjooa@yahoo.co.uk 31
Data Types
Char
For storing the character
data C language provides
char data type. By using
char data type we can
store characters in
variables. While
assigning a character
value to a char type
variable single quotes are
used around the
character as ‘a’.
 #include <iostream.h>
main()
{
char x;
x = ’a’;
cout << “The character value in x = “;
cout << x;
}
Bilal Janjooa bilal.janjooa@yahoo.co.uk 32
Arithmetic operators
Plus +
Minus -
Multiply *
Divide /
Modulus %
Bilal Janjooa bilal.janjooa@yahoo.co.uk 33
Arithmetic operators
i + j
x * y
a / b
a % b
Bilal Janjooa bilal.janjooa@yahoo.co.uk 34
% = Remainder
5 % 2 = 1
2 % 2 = 0
Bilal Janjooa bilal.janjooa@yahoo.co.uk 35
4 / 2 = 2
5 / 2 = ?
Bilal Janjooa bilal.janjooa@yahoo.co.uk 36
Precedence
 Highest: ( )
 Next: * , / , %
 Lowest: + , -
Bilal Janjooa bilal.janjooa@yahoo.co.uk 37
Bilal Janjooa bilal.janjooa@yahoo.co.uk 38

More Related Content

What's hot

C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
Computer مراجعة حاسب آلى 3 ع ت1
Computer مراجعة حاسب آلى 3 ع ت1Computer مراجعة حاسب آلى 3 ع ت1
Computer مراجعة حاسب آلى 3 ع ت1أمنية وجدى
 
Unicode Fundamentals
Unicode Fundamentals Unicode Fundamentals
Unicode Fundamentals SamiHsDU
 
Unicode Encoding Forms
Unicode Encoding FormsUnicode Encoding Forms
Unicode Encoding FormsMehdi Hasan
 
Description of VivaVisualCode
Description of VivaVisualCodeDescription of VivaVisualCode
Description of VivaVisualCodePVS-Studio
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introductionAnanda Kumar HN
 
UTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character EncodingUTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character EncodingBert Pattyn
 
Chapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-pChapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-pIIUI
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4ANILBIKAS
 
Data encryption and tokenization for international unicode
Data encryption and tokenization for international unicodeData encryption and tokenization for international unicode
Data encryption and tokenization for international unicodeUlf Mattsson
 
Jun 29 new privacy technologies for unicode and international data standards ...
Jun 29 new privacy technologies for unicode and international data standards ...Jun 29 new privacy technologies for unicode and international data standards ...
Jun 29 new privacy technologies for unicode and international data standards ...Ulf Mattsson
 

What's hot (20)

C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Computer مراجعة حاسب آلى 3 ع ت1
Computer مراجعة حاسب آلى 3 ع ت1Computer مراجعة حاسب آلى 3 ع ت1
Computer مراجعة حاسب آلى 3 ع ت1
 
Introductionof c
Introductionof cIntroductionof c
Introductionof c
 
Unicode Fundamentals
Unicode Fundamentals Unicode Fundamentals
Unicode Fundamentals
 
Unicode Encoding Forms
Unicode Encoding FormsUnicode Encoding Forms
Unicode Encoding Forms
 
Introduction To C
Introduction To CIntroduction To C
Introduction To C
 
Description of VivaVisualCode
Description of VivaVisualCodeDescription of VivaVisualCode
Description of VivaVisualCode
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introduction
 
UTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character EncodingUTF-8: The Secret of Character Encoding
UTF-8: The Secret of Character Encoding
 
Chapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-pChapter 04 computer codes 3o-p
Chapter 04 computer codes 3o-p
 
Unicode
UnicodeUnicode
Unicode
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4
 
Lecture 01
Lecture 01Lecture 01
Lecture 01
 
C language
C languageC language
C language
 
Data encryption and tokenization for international unicode
Data encryption and tokenization for international unicodeData encryption and tokenization for international unicode
Data encryption and tokenization for international unicode
 
Jun 29 new privacy technologies for unicode and international data standards ...
Jun 29 new privacy technologies for unicode and international data standards ...Jun 29 new privacy technologies for unicode and international data standards ...
Jun 29 new privacy technologies for unicode and international data standards ...
 
Handout#01
Handout#01Handout#01
Handout#01
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
How To Tame Python
How To Tame PythonHow To Tame Python
How To Tame Python
 
3.5
3.53.5
3.5
 

Similar to Introduction to Computer Languages by Bilal Janjooa

Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data sciencedeepak teja
 
python PPT Session 1.pptx
python PPT Session 1.pptxpython PPT Session 1.pptx
python PPT Session 1.pptxRobertHook14
 
A Crash Course in C Part-1
A Crash Course in C Part-1A Crash Course in C Part-1
A Crash Course in C Part-1MD SAMIR UDDIN
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYRajeshkumar Reddy
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...manikamr074
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
 
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...ANUSUYA S
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfKosmikTech1
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptxMangala R
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfComedyTechnology
 

Similar to Introduction to Computer Languages by Bilal Janjooa (20)

Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
python PPT Session 1.pptx
python PPT Session 1.pptxpython PPT Session 1.pptx
python PPT Session 1.pptx
 
A Crash Course in C Part-1
A Crash Course in C Part-1A Crash Course in C Part-1
A Crash Course in C Part-1
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Basic c
Basic cBasic c
Basic c
 
Python programming
Python programmingPython programming
Python programming
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)
 
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Adv programming languages
Adv programming languagesAdv programming languages
Adv programming languages
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
FINAL.ppt
FINAL.pptFINAL.ppt
FINAL.ppt
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
 

Recently uploaded

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

Introduction to Computer Languages by Bilal Janjooa

  • 1. Tutor: Bilal Janjooa Assistant Professor UOL MS Telecom. Eng. From University of Sunderland UK Bilal Janjooa bilal.janjooa@yahoo.co.uk 1
  • 3. 3 Machine Languages, Assembly Languages, and High-level Languages  Three types of computer languages 1. Machine language  Only language computer directly understands  “Natural language” of computer  Defined by hardware design  Machine-dependent  Generally consist of strings of numbers  Instruct computers to perform elementary operations  One at a time  Example: +1300042774 +1400593419 +1200274027 Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 4. 4 Machine Languages, Assembly Languages, and High-level Languages  Three types of computer languages 2. Assembly language  English-like abbreviations representing elementary computer operations  Clearer to humans  Incomprehensible to computers  Translator programs (assemblers)  Convert to machine language  Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 5. 5 Machine Languages, Assembly Languages, and High-level Languages  Three types of computer languages 3. High-level languages  Similar to everyday English, use common mathematical notations  Single statements accomplish substantial tasks  Assembly language requires many instructions to accomplish simple tasks  Translator programs (compilers)  Convert to machine language  Interpreter programs  Directly execute high-level language programs  Example: grossPay = basePay + overTimePay Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 6. Introduction to C++ Bilal Janjooa bilal.janjooa@yahoo.co.uk 6
  • 7. History of C and C++  History of C  Evolved from two other programming languages  BCPL and B  “Typeless” languages  Dennis Ritchie (Bell Laboratories)  Added data typing, other features  Development language of UNIX  Hardware independent  Portable programs  1989: ANSI standard  1990: ANSI and ISO standard published  ANSI/ISO 9899: 1990 7Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 8. History of C and C++  History of C++  Extension of C  Early 1980s: Bjarne Stroustrup (Bell Laboratories)  “Spruces up” C  Provides capabilities for object-oriented programming  Objects: reusable software components  Model items in real world  Object-oriented programs  Easy to understand, correct and modify  Hybrid language  C-like style  Object-oriented style  Both 8Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 9. Source code, Object code and Compiler.  Source code is the version of a computer program as it is originally written (i.e., typed into a computer) by a human in a programming language.  Object code is the output of a compiler after it processes source code.  A compiler is a specialized program that converts source code into object code. Bilal Janjooa bilal.janjooa@yahoo.co.uk 9
  • 10. 10 Phases of C++ Programs: 1. Edit 2. Preprocess 3. Compile 4. Link 5. Load 6. Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory . . . . . . . . . . . . Disk Disk Disk Disk Disk Bilal Janjooa bilal.janjooa@yahoo.co.uk
  • 11. Flow of C++ Program  Compile:Translate a program from source code to assembly code.  Assembler:Translate a program from assembly code to object code (sometimes these two steps are combined and called compiling).  Link:Pull together all of the functions needed for the program (both user defined objects and system libraries) and arrange that locations of functions and variables are known. This step creates the executable.  Load:Move the executable into computer memory.  Execute:Run the program Bilal Janjooa bilal.janjooa@yahoo.co.uk 11
  • 12. #include <iostream.h> main ( ) { cout << “ Welcome to University of Lahore “; } Bilal Janjooa bilal.janjooa@yahoo.co.uk 12
  • 13. Pre-processor directive  # include <iostream.h>  #include: This is a pre-processor directive. It is not part of our program; it is an instruction to the compiler. It tells the C compiler to include the contents of a file, in this case the system file iostream.h.  The sign # is known as HASH Bilal Janjooa bilal.janjooa@yahoo.co.uk 13
  • 14. Variable During programming we need to store data. This data is stored in variables. Variables are locations in memory for storing data. The memory is divided into blocks. X Bilal Janjooa bilal.janjooa@yahoo.co.uk 14
  • 15. Variable Variable starts with 1. Character 2. Underscore _ (Not Recommended) Bilal Janjooa bilal.janjooa@yahoo.co.uk 15
  • 16. Variable  Small post box X Bilal Janjooa bilal.janjooa@yahoo.co.uk 16
  • 17. Variable Variable is the name of a location in the memory e.g. x= 2; Bilal Janjooa bilal.janjooa@yahoo.co.uk 17
  • 18. Variable In a program a variable has: 1. Name 2. Type 3. Size 4. Value Bilal Janjooa bilal.janjooa@yahoo.co.uk 18
  • 19. Assignment Operator = x = 2 X 2 Bilal Janjooa bilal.janjooa@yahoo.co.uk 19
  • 20. X = 10 ; X = 30 ; X 10 X 30 Bilal Janjooa bilal.janjooa@yahoo.co.uk 20
  • 21. X = X + 1; 10 + 1 = X 11 Bilal Janjooa bilal.janjooa@yahoo.co.uk 21
  • 22. Data type  int i ; -> Declaration line i Bilal Janjooa bilal.janjooa@yahoo.co.uk 22
  • 23. Bilal Janjooa bilal.janjooa@yahoo.co.uk 23 #include <iostream.h> main ( ) { int x ; int y ; int z ; x = 10 ; y = 20 ; z = x + y ; cout << " x = " ; cout << x ; cout << " y = " ; cout << y ; cout << " z =x + y = " ; cout << z ; }
  • 24. int x, y, z ; int x; int y; int z ; Bilal Janjooa bilal.janjooa@yahoo.co.uk 24
  • 25. Data Types 1. int 2. short 3. long 4. float 5. double 6. char
  • 26. Data Types int The data type int is used to store whole numbers (integers). The integer type has a space of 4 bytes (32 bits for windows operating system) in memory. And it is mentioned as ‘int’ which is a reserved word of C, so we can not use it as a variable name. Bilal Janjooa bilal.janjooa@yahoo.co.uk 26
  • 27. Data Types Short We noted that the integer occupies four bytes in memory. So if we have to store a small integer like 5, 10 or 20 four bytes would be used. The C provides another data type for storing small whole numbers which is called short. The size of short is two bytes and it can store numbers in range of -32768 to 32767. So if we are going to use a variable for which we know that it will not increase from 32767 Bilal Janjooa bilal.janjooa@yahoo.co.uk 27
  • 28. Data Types Long we have a very large whole number that can not be stored in an int then we use the data type long provided by C. So when we are going to deal with very big whole numbers in our program, we use long data type. We use it in program as: long x = 300500200; Bilal Janjooa bilal.janjooa@yahoo.co.uk 28
  • 29. Real Numbers  The C language provides two data types to deal with real numbers (numbers with decimal points e.g. 1.35, 735.251). The real numbers are also known as floating point numbers.  float  double Bilal Janjooa bilal.janjooa@yahoo.co.uk 29
  • 30. Data Types float To store real numbers, float data type is used. The float data type uses four bytes to store a real number. Bilal Janjooa bilal.janjooa@yahoo.co.uk 30
  • 31. Data Types double If we need to store a large real number which cannot be store in four bytes, then we use double data type. Normally the size of double is twice the size of float. In program we use it as: double x = 345624.769123; Bilal Janjooa bilal.janjooa@yahoo.co.uk 31
  • 32. Data Types Char For storing the character data C language provides char data type. By using char data type we can store characters in variables. While assigning a character value to a char type variable single quotes are used around the character as ‘a’.  #include <iostream.h> main() { char x; x = ’a’; cout << “The character value in x = “; cout << x; } Bilal Janjooa bilal.janjooa@yahoo.co.uk 32
  • 33. Arithmetic operators Plus + Minus - Multiply * Divide / Modulus % Bilal Janjooa bilal.janjooa@yahoo.co.uk 33
  • 34. Arithmetic operators i + j x * y a / b a % b Bilal Janjooa bilal.janjooa@yahoo.co.uk 34
  • 35. % = Remainder 5 % 2 = 1 2 % 2 = 0 Bilal Janjooa bilal.janjooa@yahoo.co.uk 35
  • 36. 4 / 2 = 2 5 / 2 = ? Bilal Janjooa bilal.janjooa@yahoo.co.uk 36
  • 37. Precedence  Highest: ( )  Next: * , / , %  Lowest: + , - Bilal Janjooa bilal.janjooa@yahoo.co.uk 37