5.introduction To C Language
5.introduction To C Language
collection of characters.
particular task.
objective.
Character set:
In C programming, a character set is a set of characters that is used to
represent the letters, digits, and other symbols in a computer. The
character set refers to a set of all the valid characters that we can use in the
source program .The C programming language supports four types of
characters in its character set: Alphabets, Digits, Special characters, and
White spaces.
Tokens
Identifiers.
Literals (constants).
Variables.
Operators.
Special symbols.
Keywords:
Keywords are the pre-defined or built-in words. Each keyword has its own
definition that is defined by the language developers. A C compiler can
recognize keyword and replaces its definition whenever it is needed.
Keywords also called as reserved words. Each keyword has its own purpose
and it should be used only for that purpose. It is important to note that all
the keywords should be in lowercase.There are 3 types of keywords:
Identifiers:
As pre-defined names (i.e., keywords) are needed to develop a C program,
1Raj (invalid)
Rule #3: No special symbol is used except underscore (_). No spaces are
allowed in an identifier.
Rule #4: Upper and lower case letters in an identifier are distinct (or
Ex: The names amount, Amount, aMOUnt and AMOUNT are not the same
identifiers.
recognize only the first eight characters, though most compilers recognize
Data type
Data type is a types of data that states the possible values that can be taken,
how they are stored and what operations are allowed on them.Before we
learn variables we need to know regarding data types since variables have
to be associated with data types in prior before used since C is statically
typed language.
Basic data types: The fundamental data types in C, such as integers, float,
characters, double and void are used to represent simple values and are
known as the "basic data types.".They are also referred as primitive data
types or built-in data types or primary data types.
Data type Size (in bytes)
float 4 bytes
double 8 bytes
char 1 byte.
void 0 bytes.
Type modifiers: Except the data type void, the primitive data types may
have various type modifiers preceding them. Type modifiers are the
keywords that are used to modify the behaviour of existing primitive data
16-bit 2 2 4
32-bit 2 4 4
b)Sign modifiers: if unsigned type modifier is preceding a primitive data
type, then the variables of the specified type accept only positive values. If
signed type modifier is preceding a primitive data type, then the variables
The format specifier in C is used to tell the compiler about the type of data
start with a % symbol and are used in the formatted string in functions
Derived and User-defined data types: These are the data types derived from
primitive data types and few are defined by the user according to his needs.
These data types will be defined by using primitive data types. The derived
union, enum.
Array : An array in C is a fixed-size collection of similar data items stored
in contiguous memory locations.
A variable is a named location in memory that holds a value and that value
the program. The variable declaration tells the compiler two things:
built based on the rules of identifier. If there are more than one
as follows:
[Storage class] <data type> <variable name>=<value>; ….(1)
(or)
[Storage class] <data type> <variable name>;
<variable name>=<value>; ….(2)
(or)
[Storage class] <data type> <variable name>;
Using scanf() read value that has to be initialized …..(3)
In these first two syntaxes, we observe an operator, i.e., assignment operator
int a;
Dynamic
initialization
scanf(“%d”,&a);
Dynamic Initialization: Here, the variable is assigned a value at the run time.
The value of this variable can be altered every time the program is being
run.
Type qualifiers
Type qualifiers are the keywords that add new meanings to existing data
This initialization tells the compiler that the value of PI must not be
x=PI;
volatile int x;