SlideShare a Scribd company logo
1 of 23
Introduction to C++
Language Datatypes
Lecture 5
1
Levels of Programming Languages
There are 3 levels of programming
languages
i) High-Level Language
ii) Middle-Level Language
iii) Low-Level Language
2
Uses of C/C++ Programming Language
Areas where C/C++ language can be used are
 Operating Systems
 Network Drivers
 Communication Packages
 Databases
 Language Interpreters
 Utilities
 Language Compilers
 Spreadsheets
 Text Editors
 etc etc
3
C/C++ Character Set
C/C++ character set comprises of
following characters
 A,B,C,….Z
 a,b,c,…...z
 0,1,2,……9
 , . ; : ? ! “ / ‘  | ~
 ( ) [ ] { } < >
 + - # % _ ^ = & *
4
White Space Characters
 The character that produces blank
space when printed is called a white
space character, e.g.
 Spaces
 Tabs
 New Lines
5
Data Transformation
 Programs transform data from one form to another
 Input data  Output data
 Stimulus  Response
 Programming languages store and process data in
various ways depending on the type of the data;
consequently, all data read, processed, or written
by a program must have a data type
 Two distinguishing characteristics of a programming
language are the data types it supports and the
operations on those data types
6
Data Handling
 Various types of data
 E.g. letters, numbers, symbols, etc.
 Data handling requires different data types
 Data Type: type of data that a variable
can hold and the operations that can be
performed on it.
 Logical to ask the computer to multiply a
float by an integer (1.5 x 5)
 Illogical to ask the computer to multiply a
float by a string (1.5 x FUI)
Constants & Variables
 Constants
 1, 56, 1.89, ’a’, ’Z’, ”BSSE”
 Variables
x = 5
y = 20
8
What is Data Type
 A data type is a set of values, together with a set of
associated operations on those values.
 Here is the table for different types:-
Date Type Used for Examples
String
Alphanumeric
characters
“hello world”, “Islamabad”,
“Alice”
Integer Whole numbers 7, 12, 999, -47
Float (floating
point)
Number with a decimal
point
3.15, 9.06, 00.13
Character
Single alphabet or
number
‘A’, ‘9’, ‘&’ (uses ASCII)
Boolean
Representing logical
values
True, False
A Data Type
 A data type is
 A set of values AND
 A set of operations on those values
 A data type is used to
 Identify the type of a variable when the
variable is declared
 Identify the type of the return value of a
function
 Identify the type of a parameter expected
by a function
10
A Data Type (continued)
 When the compiler encounters a declaration for
a variable, it sets up a memory location for it
 An operator used on a variable or variables is
legal only if
 The operator is defined in that programming
language for a variable of that type
 The variable or variables involved with the
operator are of the same or compatible
types
11
C++ Data Types
C++ Data
Types
Primitive /
Built-in
Derived
User
Defined
Primitive Built-in Data Types
Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t
Primitive Built-in Data Types
Many of the above data types can be modify
using these modifiers:-
 signed
 unsigned
 short
 long
Variable Types and Memory Used
Type
Typical Size
(Byte)
Typical Range
char 1 byte -128 to 127
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 4 bytes
-2147483648 to
2147483647
unsigned int 4 bytes 0 to 4294967295
signed int 4 bytes
-2147483648 to
2147483647
Variable Types and Memory Used
Type
Typical Size
(Byte)
Typical Range
short int 2 bytes -32768 to 32767
unsigned short int 2 bytes 0 to 65,535
signed short int 2 bytes -32768 to 32767
long int 8 bytes
-
9,223,372,036,854,775,808
to
9,223,372,036,854,775,807
signed long int 8 bytes
-
9,223,372,036,854,775,808
to
9,223,372,036,854,775,807
unsigned long int 8 bytes
0 to
18,446,744,073,709,551,61
5
Variable Types and Memory Used
Type
Typical Size
(Byte)
Typical Range
float 4 bytes
-3.4 x 1038 to +3.4 x 1038
(~7 digits)
double 8 bytes
-1.7 x 10308 to +1.7 x 10308
(~15 digits)
wchar_t 2 or 4 bytes 1 wide character
Data Types
 Boolean: for storing true or false values.
Boolean variables are declared using the
keyword bool
 String: generally means an ordered
sequence of characters, enclosing
delimiters are double quotes “some string“.
Declared using keyword string
 The sizes of variables might be different
from those shown in the above table,
depending on the compiler and the
computer you are using.
18
Variable Declaration
When variables are declared of a
particular data type then
 the variable becomes the place where the
data is stored, and
 data types is the type of value(data) stored
by that variable.
int var;
int is the datatype of the variable,
var is the variable name
; is statement terminator
Identifiers
Identifiers refer to the names of
 data types, constants, variables, and
functions
 Cannot be keywords
20
Rules for Constructing Identifiers in C++
 Can contain letters, digits and underscores,
capital letters A-Z, lowercase letters a-z,
digits 0-9, and the underscore character _
 Digit can not be the first character.
 First character must be a letter or
underscore
 Can not consist of an underscore alone.
 Usually only the first 32 characters are
significant.
21
Rules for Constructing Identifiers in C++
(contd.)
 May not be same as keyword or function
name etc.
 There can be no embedded blanks (spaces
are not allowed).
 Keywords cannot be used as identifiers
 Identifiers are case sensitive
22
Types of C/C++ Instructions
There are 4 types of C/C++ Instructions.
i) Type declaration Instructions
Variable types and definitions etc.
ii) Input/Output Instructions
Data Input, Data Display, Data Write
etc
iii) Control Instructions
Controls the sequence of execution of
the program instructions.
iv) Arithmetic Instructions
Arithmetic Operations etc
23

More Related Content

Similar to 5-Lec - Datatypes.ppt

Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageRai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageRai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageRai University
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c languageRai University
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptxmadhurij54
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++K Durga Prasad
 
Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Ankur Pandey
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1Hossein Zahed
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 

Similar to 5-Lec - Datatypes.ppt (20)

Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
C++
C++C++
C++
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Data Handling
Data HandlingData Handling
Data Handling
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++
 
C#
C#C#
C#
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C presentation book
C presentation bookC presentation book
C presentation book
 

More from AqeelAbbas94

lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdlecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdAqeelAbbas94
 
1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).pptAqeelAbbas94
 
2-Lec - History of OOP and Java (1) .ppt
2-Lec - History of OOP and Java  (1) .ppt2-Lec - History of OOP and Java  (1) .ppt
2-Lec - History of OOP and Java (1) .pptAqeelAbbas94
 
Lecture-32-33.pptx
Lecture-32-33.pptxLecture-32-33.pptx
Lecture-32-33.pptxAqeelAbbas94
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptxAqeelAbbas94
 
use_case+use_case description.pptx
use_case+use_case description.pptxuse_case+use_case description.pptx
use_case+use_case description.pptxAqeelAbbas94
 
555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.pptAqeelAbbas94
 
12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptxAqeelAbbas94
 
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...AqeelAbbas94
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.pptAqeelAbbas94
 
Your Title goes Here.pptx
Your Title goes Here.pptxYour Title goes Here.pptx
Your Title goes Here.pptxAqeelAbbas94
 

More from AqeelAbbas94 (20)

lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdlecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
 
1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt
 
2-Lec - History of OOP and Java (1) .ppt
2-Lec - History of OOP and Java  (1) .ppt2-Lec - History of OOP and Java  (1) .ppt
2-Lec - History of OOP and Java (1) .ppt
 
Lecture-32-33.pptx
Lecture-32-33.pptxLecture-32-33.pptx
Lecture-32-33.pptx
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx
 
blue.pptx
blue.pptxblue.pptx
blue.pptx
 
use_case+use_case description.pptx
use_case+use_case description.pptxuse_case+use_case description.pptx
use_case+use_case description.pptx
 
555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt
 
12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx
 
hexagon.pptx
hexagon.pptxhexagon.pptx
hexagon.pptx
 
Lecture1.ppt
Lecture1.pptLecture1.ppt
Lecture1.ppt
 
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
 
lecture56.ppt
lecture56.pptlecture56.ppt
lecture56.ppt
 
04.ppt
04.ppt04.ppt
04.ppt
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 
SelectionSort.ppt
SelectionSort.pptSelectionSort.ppt
SelectionSort.ppt
 
Lecture2 (1).ppt
Lecture2 (1).pptLecture2 (1).ppt
Lecture2 (1).ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
Your Title goes Here.pptx
Your Title goes Here.pptxYour Title goes Here.pptx
Your Title goes Here.pptx
 
SE_models_1.ppt
SE_models_1.pptSE_models_1.ppt
SE_models_1.ppt
 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
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
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
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
 
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
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 

Recently uploaded (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
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
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
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
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
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
 
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
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 

5-Lec - Datatypes.ppt

  • 1. Introduction to C++ Language Datatypes Lecture 5 1
  • 2. Levels of Programming Languages There are 3 levels of programming languages i) High-Level Language ii) Middle-Level Language iii) Low-Level Language 2
  • 3. Uses of C/C++ Programming Language Areas where C/C++ language can be used are  Operating Systems  Network Drivers  Communication Packages  Databases  Language Interpreters  Utilities  Language Compilers  Spreadsheets  Text Editors  etc etc 3
  • 4. C/C++ Character Set C/C++ character set comprises of following characters  A,B,C,….Z  a,b,c,…...z  0,1,2,……9  , . ; : ? ! “ / ‘ | ~  ( ) [ ] { } < >  + - # % _ ^ = & * 4
  • 5. White Space Characters  The character that produces blank space when printed is called a white space character, e.g.  Spaces  Tabs  New Lines 5
  • 6. Data Transformation  Programs transform data from one form to another  Input data  Output data  Stimulus  Response  Programming languages store and process data in various ways depending on the type of the data; consequently, all data read, processed, or written by a program must have a data type  Two distinguishing characteristics of a programming language are the data types it supports and the operations on those data types 6
  • 7. Data Handling  Various types of data  E.g. letters, numbers, symbols, etc.  Data handling requires different data types  Data Type: type of data that a variable can hold and the operations that can be performed on it.  Logical to ask the computer to multiply a float by an integer (1.5 x 5)  Illogical to ask the computer to multiply a float by a string (1.5 x FUI)
  • 8. Constants & Variables  Constants  1, 56, 1.89, ’a’, ’Z’, ”BSSE”  Variables x = 5 y = 20 8
  • 9. What is Data Type  A data type is a set of values, together with a set of associated operations on those values.  Here is the table for different types:- Date Type Used for Examples String Alphanumeric characters “hello world”, “Islamabad”, “Alice” Integer Whole numbers 7, 12, 999, -47 Float (floating point) Number with a decimal point 3.15, 9.06, 00.13 Character Single alphabet or number ‘A’, ‘9’, ‘&’ (uses ASCII) Boolean Representing logical values True, False
  • 10. A Data Type  A data type is  A set of values AND  A set of operations on those values  A data type is used to  Identify the type of a variable when the variable is declared  Identify the type of the return value of a function  Identify the type of a parameter expected by a function 10
  • 11. A Data Type (continued)  When the compiler encounters a declaration for a variable, it sets up a memory location for it  An operator used on a variable or variables is legal only if  The operator is defined in that programming language for a variable of that type  The variable or variables involved with the operator are of the same or compatible types 11
  • 12. C++ Data Types C++ Data Types Primitive / Built-in Derived User Defined
  • 13. Primitive Built-in Data Types Type Keyword Boolean bool Character char Integer int Floating point float Double floating point double Valueless void Wide character wchar_t
  • 14. Primitive Built-in Data Types Many of the above data types can be modify using these modifiers:-  signed  unsigned  short  long
  • 15. Variable Types and Memory Used Type Typical Size (Byte) Typical Range char 1 byte -128 to 127 unsigned char 1 byte 0 to 255 signed char 1 byte -128 to 127 int 4 bytes -2147483648 to 2147483647 unsigned int 4 bytes 0 to 4294967295 signed int 4 bytes -2147483648 to 2147483647
  • 16. Variable Types and Memory Used Type Typical Size (Byte) Typical Range short int 2 bytes -32768 to 32767 unsigned short int 2 bytes 0 to 65,535 signed short int 2 bytes -32768 to 32767 long int 8 bytes - 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 signed long int 8 bytes - 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 unsigned long int 8 bytes 0 to 18,446,744,073,709,551,61 5
  • 17. Variable Types and Memory Used Type Typical Size (Byte) Typical Range float 4 bytes -3.4 x 1038 to +3.4 x 1038 (~7 digits) double 8 bytes -1.7 x 10308 to +1.7 x 10308 (~15 digits) wchar_t 2 or 4 bytes 1 wide character
  • 18. Data Types  Boolean: for storing true or false values. Boolean variables are declared using the keyword bool  String: generally means an ordered sequence of characters, enclosing delimiters are double quotes “some string“. Declared using keyword string  The sizes of variables might be different from those shown in the above table, depending on the compiler and the computer you are using. 18
  • 19. Variable Declaration When variables are declared of a particular data type then  the variable becomes the place where the data is stored, and  data types is the type of value(data) stored by that variable. int var; int is the datatype of the variable, var is the variable name ; is statement terminator
  • 20. Identifiers Identifiers refer to the names of  data types, constants, variables, and functions  Cannot be keywords 20
  • 21. Rules for Constructing Identifiers in C++  Can contain letters, digits and underscores, capital letters A-Z, lowercase letters a-z, digits 0-9, and the underscore character _  Digit can not be the first character.  First character must be a letter or underscore  Can not consist of an underscore alone.  Usually only the first 32 characters are significant. 21
  • 22. Rules for Constructing Identifiers in C++ (contd.)  May not be same as keyword or function name etc.  There can be no embedded blanks (spaces are not allowed).  Keywords cannot be used as identifiers  Identifiers are case sensitive 22
  • 23. Types of C/C++ Instructions There are 4 types of C/C++ Instructions. i) Type declaration Instructions Variable types and definitions etc. ii) Input/Output Instructions Data Input, Data Display, Data Write etc iii) Control Instructions Controls the sequence of execution of the program instructions. iv) Arithmetic Instructions Arithmetic Operations etc 23