BCSC 1102 Introduction to Programming Lecture 2 PPT
BCSC 1102 Introduction to Programming Lecture 2 PPT
Integer Types
Floating-Point Types
Character Type
Scope refers to the region of the program where the variable can be
accessed.
Types: Local Scope, Global Scope, Block Scope.
The short modifier reduces the storage size of the integer type.
The long modifier increases the storage size of the integer type.
When used with double, long increases the precision.
The short modifier is used to reduce the storage size of the integer
type.
Example: short int a = 1000; // Short integer short b = 2000; // Short
integer (int can be omitted)
The long modifier increases the storage size of the integer type.
When used with double, it increases the precision.
Example: long int a = 100000L; // Long integer long b = 200000L; //
Long integer (int can be omitted) long long c = 100000000000LL; //
Long long integer
double x = 3.14; long double y = 3.141592653589793238L; // Long
double for higher precision
The storage size and value ranges of modified data types depend on
the system architecture (32-bit vs. 64-bit) and the compiler.
Overview:
short: 2 bytes, range: -32,768 to 32,767 (signed), 0 to 65,535
(unsigned)
int: 4 bytes, range: -2,147,483,648 to 2,147,483,647 (signed),
0 to 4,294,967,295 (unsigned)
long: 4 or 8 bytes, range: depends on the system
long long: 8 bytes, range: -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 (signed), 0 to
18,446,744,073,709,551,615 (unsigned)
float: 4 bytes, range: 1.2E-38 to 3.4E+38
double: 8 bytes, range: 2.3E-308 to 1.7E+308
long double: 10, 12, or 16 bytes, range: depends on the system
The Co-operatetive University of Kenya Sep
Dr. Shem Mbandu Angolo, PhD BCSC 1102 : Intro To Programming Week 2 41 / 65
Constants and Literals
1 Basic Structure of a C Program
Preprocessor Directives
Global Declarations
The main() Function
Variable Declarations
Function Definitions
Statements and Expressions
Comments
Example
Explanation of the Example
2 Data Types
Basic Data Types
Integer Types
Floating-Point Types
Character Type
Derived Data Types
User-Defined Data Types
3 Variables in C The Co-operatetive University of Kenya Sep
Dr. Shem Mbandu Angolo, PhD BCSC 1102 : Intro To Programming Week 2 42 / 65
Constants