1. 'C's Character Set 2. C Tokens 3. Identifiers and Keywords 4. Data Types 5. Variables, Constants and delimeters 6 Constants 7. Delimiters 8. Statements
CONSTANTS, VARIABLES, KEYWORDS AND
DATA TYPES
The
character set is the fundamental raw material of any language and they are used
to represent information. Like natural languages, computer language will also
have well defined character set, which is useful to build the programs.
The
classical method of learning English language is learning first the alphabets
or characters used in the language. Thus learn to combine these alphabets to
plan for words, which in turn are combined to form sentences and sentences are
combined to form paragraphs. Similarly the characters used to write 'C' program
are basically of two types, namely
i)
Source character set
ii)
Execution character set

These
are used to construct the statements in the source program.
These
are of four types;

These
are employed at the time of execution. This set of characters are also called
as non graphic characters because, these characters are invisible and cannot be
printed or displayed directly. These characters will have effect only when the
program is being executed. Execution characters set are always represented by a
backslash (\) followed by a character. These are also called as 'escape
sequences.'

The
tokens are usually referred as individual text and punctuation in a passage of
text. The 'C' language program can contain the individual units called the C
tokens and has the following types.

In
'C' language every word is classified into either a keyword or an identifier.
Identifiers:
Identifiers are names given to various program elements, such as variables,
functions and arrays etc.
•
Identifiers consist of letters and digits in any order.
•
The first character must be a character or may begin with (_).
•
Both upper/lower cases allowed although uppercase character is not equivalent
to corresponding lowercase character.
•
The underscore '_' is considered as a letter.
•
An identifier can be of any length while most of the 'C' compiler recognizes
only the first 31 characters.
•
No space and special symbols are allowed between the identifier.
Some
valid Identifiers are
STDNAME, SUB, TOT MARKS, TEMP, Y2K.
Some
invalid Identifiers are
Return, $stay, 1RECORD, STD NAME.
Keyword:
There are certain reserved words called keywords that have standard and
predefined meaning in 'C' language. Which cannot be changed and they are the
basic building blocks for program statements. The 'C' keywords are listed
below.
Table of ANSI 'C' keywords
auto break case char const continue default do double enum else extern for goto if int long return register signed short static sizeof struct switch typedef union unsigned void volatile while
All
keywords must be written in lower case
Data
type is the type of the data, that are going to access within the program. 'C'
supports different data types, each data type may have predefined memory
requirement and storage representation.
'C'
supports the following 4 classes of data types

The
bytes occupied by each of the primary data types are

The
primary data types are divided into the following.

a) Integer type:
Integers are the numbers with the supported range. Usually the integers occupy
one word of storage typically 16 or 32 bits. The size of the integer depends
upon the system.
Eg:
For 16 bit, the size can be limited up to ‒32768 to +32767.
b) Character type:
Characters are generally stored in 8 bits of the internal storage of computer
and a single character can be defined as char data type.
c) Float type:
The floating point numbers are generally stored in 32 bits with the 6 digits of
precision. These numbers are defined by using the keywords float and double,
whereas the double data type uses the 64 bits with 14 digits of precision.
d) Null data type:
The void is the null data type in 'C' language. This is generally specified
with the function which has no arguments.
If
we use a 16 bit word length, size of data type is limited to the specific
range. So in order to provide some control over the range of numbers and
storage space of the data type, some basic data types can be argumented by
using the data type qualifiers, they are,
short, long, signed, unsigned
The
declaration of long and unsigned integer permits us to increase the range of
values. The precedence of signed declaration for an integer is essential as the
default declaration assumes signed numbers.
Sizes
and Ranges of data types with type qualifiers

A
Variable is an identifier that is used to represent some specified type of
information within a designated portion of the program. A variable may take
different values at different times during the execution. i.e. it is the named
memory location.
After
designing suitable variable names, we must declare them in a program, and this
declaration tells the compiler what the variable name and type of the data that
the variable will hold.
Syntax: data type v1, v2,
v3......., vn;
Description:
data type
v1, v2, v3....,vn - is the type of the data are the list of variables
Example:
int code;
char gender;
float price;
char name[10];
Here
the variables, code is type of integer, gender is type of character, price is
type of float and name[10] is defined an array of character.
The
data item must be assigned to the variable at some part of the program. The
data item can then be accessed later in the program simply by referring to the
variable name.
Initialization
of variables can be done using the assignment operator (=). The variables can
be initialized while declaration itself.
Syntax:
Variable
= constant;
Description:
i,f,c are
the type of int, float, char data types
Example:
int;
float f;
char c;

a) Type declaration:
'C' Language provides a feature to declare a variable of the type of user
defined type declaration. This allows users to define an identifier that would
represent an existing data type and this can later be used to declare
variables.
The
typedef is a keyword in the C programming
languages. The purpose of typedef is to form complex types from more basic
machine types and assign simpler names to such combinations. They are most
often used when a standard declaration is cumbersome, potentially confusing, or
likely to vary from one implementation to another.
Syntax:
typedef
data_type identifier;
Description:
typedef is the user defined type declaration,
data_type is the existing data type,
identifier is the identifier refers to the new
name given to the data type.
Example
typedef int marks;
marks m1, m2, m3;
Here
marks is the type of int and this can be later used to declare

b) Enumerated data type:
The C language provides another user defined data type called enumerated data
type.
Syntax:
enum
identifier {value 1, value 2,…. value n};
Description:
identifier
is the user defined enumerated data type. value 1, value 2, value n are the
enumeration constants
Example:
enum day {mon, tue,
wed,...., sun};
enum day w_st, w_end;
w_st = mon;
w_end = sun;
In
C, an enumerated data type is a data type consisting of a set of named values
called elements, members or enumerators of the type. The enumerator names are
usually identifiers that behave as constants in the language. A variable that
has been declared as having an enumerated type can be assigned any of the
enumerators as a value.

The
identifier follows with the keyword enum is used to declare the variable, that
can have only one value from the enumeration constants.
NOTE:
The compiler assigns integer values from 0 to all the enumeration constants
automatically.
Scope
of a variable implies the availability of variables within the program.
Variables have two types of scopes described below.
i) Local Variables:
The variables which are defined inside a function block or inside a compound
statement of a function sub‒program are called local variables.
Example:
function()
{
int i, j;
/* body of the
function*/
}
The
integer variables i, j are defined inside the function block of function(). Hence ij are called local
variables i.e., the availability of the variables i, j are local to that
function only in which they are declared.
ii) Global/External Variables:
The variables that are declared before the function main() are called the global/external
variables. These are available for all the functions inside the program.
Example:
int a,b=2;
main()
{
……..
fun();
}
fun()
{
int sum;
sum=a+b;
}
The
integer variables a, b are global/external
variables, as they are declared before the function main(). These global/external
variables are later used in the function sub program fun().
The
item whose values cannot be changed during the execution of program are called
constants. 'C' constants can be classified as follows.

a) Integer Constants:
An integer constant formed with the sequence of digits. There are three types
of integer constants which forms different number system.
Decimal
number - 0 to 9
Octal
number - 0 to 7
Hexadecimal
number - 0 to 9, A, B, C, D, E, F
Example:
Marks = 90;
Per = 75;
Discount = 15;
There
are basically three types of integer namely,
Decimal - Eg: 10, 153, ‒321, 019, etc.
Octal - Eg: 037, 0, 052, 0541, etc.
Hexadecimal - Eg: 0x4, 0x8F, 0xBCF etc.
b) Real Constants:
A real constant is made up of a sequence of numeric digits with presence of a
decimal point. Real constants serve as a good purpose to represent quantities
that vary continuously such as distance, heights, temperatures etc.
Example:
distance = 126.0;
height = 5.6;
speed = 3e11;
a) Single Character Constants:
The character constant contains a single character enclosed within a pair of
single inverted commas both pointing to the left.
Example:
's', 'M', '3', '-'
b) String Constants:
A string constant is a sequence of characters enclosed in double quotes, the
characters may be letters, numbers, special characters and blank spaces etc. At
the end of string '\0' is automatically placed.
Example:
"HI"
"Muni"
"39.77"
c) Declaring a variable as
constant: When the value of some of the variables may remain
constant during the execution of the program. In such a situation, this can be
done by using the keyword const.
Syntax:
const
datatype variable = constant
Description:
const is the keyword to declare constant
variable is the name of the variable
datatype is the type of the data
constant is the constant
Example: const int dob‒3977;
d) Declaring a variable as
volatile: The volatile variables are those variables that are
changed at any time by other external program or the same programe. ANSI standard
defines qualifier as volatile.
Syntax:
volatile
datatype variable = constant
Description:
volatile is the keyword to declare volatile
variable is the name of the variable
datatype is the type of the data
constant is the constant
Example: volatile int
year=2007;
The
value of a variable declared as volatile
can be modified by its own program as well If the value of a variable in the
current program is to be maintained constant and desired not to be changed by
any other external operation.
These
are the symbols, which has some syntactic meaning and has got significance.
These will not specify any operation. 'C' language delimiters list is given
below.

Statements
can be defined as a set of declaration, or sequence of action. Statement causes
the computer to perform some action. All statements in 'C' language ends with
semicolon except conditioned and control structured. The types of statements
are as follows:
1.
Assignment statements
Here,
the assignment operator is used for assigning values to the variables.
Example:

2.
Null statements
A
statement without any characters and it has only semicolon is called null
statement.
Example:
; (null statement)
3.
Block of statements
Block
contains several statements that are enclosed within a pair of braces {}. These
can be of any expression, assignments and keywords etc.
Example:

4.
Expression statements
These
consists of expressions and can be arithmetic, relational or logical.
Example:
a=29;
b=a+77;
fun(a,b);
Computer Programming C: UNIT I: Introduction to C : Tag: Computer Science : - C Programming: Constants, Variables, Keywords and Data Types
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation