0% found this document useful (0 votes)
8 views

Lecture Note-01-1

The C character set includes alphabets, digits, and special characters. It also uses escape sequences like \n for newline. Identifiers follow rules like starting with a letter and being less than 32 characters. Keywords are reserved words with specific meanings. Data types include primary types like char and int, and secondary types like pointers and arrays. Constants and variables are declared with specific rules depending on their type.

Uploaded by

Sidtan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture Note-01-1

The C character set includes alphabets, digits, and special characters. It also uses escape sequences like \n for newline. Identifiers follow rules like starting with a letter and being less than 32 characters. Keywords are reserved words with specific meanings. Data types include primary types like char and int, and secondary types like pointers and arrays. Constants and variables are declared with specific rules depending on their type.

Uploaded by

Sidtan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

 C Character set

 All the characters which can appear in a valid C program is called as Character Set of
C.
Alphabets : A-Z, a-z
Digits : 0-9
Special Characters : comma, semicolon, * etc.
 Escape Sequence :
These are non-printing characters which instruct the computer to take certain action.
They consist of a backslash followed by a letter.

Following are some backslash characters


Character Meaning

\b Back space
\n New line

\t Horizontal tab

\” Double quote

\v Vertical tab

\a Alert or bell

 Identifiers in C language:
• An identifier is used to designate program elements like variables, constants, array
names, function names.
Rules for constructing identifiers :
• First character should be an alphabet or underscore.
• Succeeding characters might be digits or letters.
• Punctuation and special characters are not allowed except underscore.
• Identifiers should not be keywords.
• Identifier can have maximum 31 characters (ANSI C standards)
 Keywords in C language:
• Keywords are pre-defined words in C.
• They are also called as reserved words.
• Their meaning is already known to the compiler.
• Each keyword is meant to perform a specific function in a C program.

• There are 32 keywords in C.


auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

 Data Types
• Primary Data Types (Basic Types)
• Derived Data Types (Secondary Types)

1. Primary Types 2. Secondary Types


 character  Pointers
 integer  Arrays
 double  Structures
 float  Unions
 void  enum
Constants

A constant is an entity that doesn’t change whereas a variable is an entity that may change.

Rules for Constructing Integer Constants


 An integer constant must have at least one digit.
 It must not have a decimal point.
 It can be either positive or negative.
 If no sign precedes an integer constant it is assumed to be positive.
 No commas or blanks are allowed within an integer constant.
 The allowable range for integer constants is -32768 to 32767.
(For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767. For a 32-bit
compiler the range would be even greater.)

Rules for Constructing Real Constants


 Real constants are often called Floating Point constants. The real constants could be
written in two forms—Fractional form and Exponential form.
Rules for constructing real constants expressed in fractional form:
 A real constant must have at least one digit.
 It must have a decimal point.
 It could be either positive or negative.
 Default sign is positive.
 No commas or blanks are allowed within a real constant.
The exponential form of representation of real constants is usually used if the value of the
constant is either too small or too large.
In exponential form of representation, the real constant is represented in two parts. The part
appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.
Rules for constructing real constants expressed in exponential form:
 The mantissa part and the exponential part should be separated by a letter e.
 The mantissa part may have a positive or negative sign.
 Default sign of mantissa part is positive.
 The exponent must have at least one digit, which must be a positive or negative integer.
Default sign is positive.
 Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.

Rules for Constructing Character Constants


 A character constant is a single alphabet, a single digit or a single special symbol enclosed
within single inverted commas.
 The maximum length of a character constant can be 1 character.

Variables

An entity that may vary during program execution is called a variable.

Variable names are names given to locations in memory. These locations can contain integer,
real or character constants.

In any language, the types of variables that it can support depend on the types of constants that
it can handle. This is because a particular type of variable can hold only the same type of
constant. For example, an integer variable can hold only an integer constant, a real variable can
hold only a real constant and a character variable can hold only a character constant.

Rules for Constructing Variable Names


 The length of variable name should not be normally more than any combination of eight
alphabets, digits, and underscores.
 The first character in the variable name must be an alphabet or underscore.
 No commas or blanks are allowed within a variable name.
 No special symbol other than an underscore can be used in a variable name.
 A variable name should not be a C keyword.
Syntax of declaring a variable:

data-type variable;

Example :

int x;

You might also like