Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Delhi Public School

Bangalore East
Cambridge International
ACADEMIC SESSION 2021-22
GRADE 8
Constants, Variables &
Data Types
Character set

 Alphabets: A-Z, a-z


 Digits: 0-9
 Symbols: `~!@#$%^&*()_-=+[]\;’,./{}|:”<>?
Constants

 An entity that does not change its value.

 Integer constant int


 Real constant float, double
 Character constant char ‘G’
 String constant String “Communication”

❖ For a String the ‘\0’ character is automatically appended at the end.


Keywords & Identifiers
Variables

 Variables are storage where we can store values of specific types.


 Each variable has its own variable name which should follow the below rules:
 A-Z, a-z, 0-9
 Underscore(_) is the only special character allowed
 A variable name can start with underscore
 Keyword cannot be a variable name
 Variables like ‘G’ and ‘g’ are different, since C is case sensitive.
 Uppercase is different from lowercase
Declaration syntax of variable

 data type variablename1, variablename2, … ;

 Eg: int x=0;


Float b;
Declaration of constant

 const data type variablename1, variablename2,…;

 Eg:
const int y=5;
const string z=“ICT”;
Basic Data Types in C

 Integer int 2 bytes


 Character char 1 byte
 Floating point float 4 bytes
 Double precision floating point double 8 bytes
 Void void
Data types & sizes

 Refer book pg: 48 [Table]


Storage type qualifier

 Const - used to declare a variable as constant whose value does not change

 Volatile - used to declare explicitly the value of some variables that can be
changed by its own/other program
 Eg:
 volatile int a; ---- can be changed by both own/external program
 volatile const int b; ---- can be changed by external program but not by own program

You might also like