CONSTANTS, VARIABLES & DATA TYPES

advertisement
CONSTANTS, VARIABLES & DATA TYPES
The characters in C are grouped into the following categories:
1.
2.
3.
4.
Letters
Digits
Special characters
White spaces
Keyword and identifiers:
Every C word is classified as either a keyword or an identifier. All keyword has fixed meaning and these
meanings can not be changed. All keywords must be written in lowercase.
Ansi C keyword:
auto
break
long
char
do
if
sizeof
while
double
else
switch
const
float
return
typedef
static
int
struct
case
continue
for
short
union
volatile
register
default
goto
signed
void
Constants:
1.
2.
3.
4.
5.
Integer constants
Real constants
Single character constants
String constants
Baclslash character constants
Variables:
A variable is a data name that may be used to store a data value. Variables names may consist of letters,
digits and underscore character, subject to the following conditions:
1.
2.
3.
4.
5.
They must begin with a letter.
The length should not be normally more than eight characters .
Uppercase and lowercase are significant.
The variable name should not be a keyword.
White space is not allowed.
CONSTANTS, VARIABLES & DATA TYPES
Data types:
Primary data types:
1. Integral type:
int
short int
long int
character
signed char
unsigned char
float
float
double
long double
Size and range of data types:
Data type
char
int
float
double
Range of values
-128 to 127
-32,768 to 32,767
3.4e-38 to 3.4 e+38
1.7e_308 to 1.7e+308
Declaration of variables:syntax:
Data_type v1, v2, …….vn;
V1, v2, …vn are the names of variables separated BY commas, ended with a semicolon.
Assigning values to variables:
Assignment statement:
Variable_name=constant;
Download