About Me

Hey friends! My name is yuvraj basnet. I'm going to introduce myself.I have born and grown up in india(chandigarh) and I'm studying second year of B.C.A computer science field. My father serving in indian air force. My mother has been taking care of house hold. I am a friendly person, good thinker, I can work for longer hours without any break, only if I'm interested in that...My life style is very simple.

VARIABLE AND TOKENS

In this tutorial, you will learn about variables, declaration of variable, smallest    individual unit of C (TOKEN) and parts of token.

                                                

                                  VARIABLE

A variable is a name of memory location. It is used to store data. Its value can be changed and it can be reused many times.

SYNTAX TO DECLARE THE VARIABLE-

Datatype variable_ list;

Example -

int a;
float b;
char c;

TOKEN-

DEFINITION OF TOKEN-

The smallest individual elements or units in a program are called as Tokens.

C has following tokens :

1) Identifiers.
2) Keywords.
3) Constants.
4) Operators.
5) Special characters.

1- DEFINITION OF IDENTIFIERS -

Identifiers in c refer to the name of the variables, functions, arrays,etc. created by the programmer, using the combination of following characters.

Example -

1) Digits :0 to 9
2) Underscore : _
3) Alphabets :A to Z (or)a to z.

RULES FOR AN IDENTIFIERS-

A) Keywords are not allowed to be used as Identifiers.

B) The first character of an identifier can only contain alphabet(a-z , A-Z) or underscore (_).

C) An Identifier can only have alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).

D) Identifiers are also case sensitive in C. For example name and Name are two different identifiers in C.

E) No special characters, such as semicolon, period, whitespaces, slash or comma are permitted to be used in or as Identifier.

2 -DEFINITION OF KEYWORD-

Keywords are the words whose meaning has been already explained by the compiler. That means at the time of designing a language, some words are reserved to do  specific tasks. Such words are called as keywords (or) reserved words.

 All C compilers support 32 keywords-



3- DEFINITION OF CONSTANTS -

Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.

TYPES OF CONSTANTS-

A) Integer constants.
B) Character constants.
C) floating point constants.
D) String constants.

A) INTEGER CONSTANTS-

Integer constants are whole numbers without any fractional part. Integer constant can be written in three different number systems: Decimal, Octal and Hexadecimal.

B) CHARACTER CONSTANTS-

A character constant is a single character, enclosed in single quotation marks.

Example -., ‘A’  ‘B’ ‘1’.

C) FLOATING POINT CONSTANTS-

A floating point constant is a base-10 number that contains either a decimal point or an exponent or both. A floating point constant can be written in two forms: Factorial form or Exponential form.

D) STRING CONSTANTS-

A string constant consists of zero or more character enclosed in quotation marks. Several string constants are given below.

Example -
“programming easily learn”.

4- DEFINITION OF OPERATOR-

The symbols which are used to perform logical and mathematical operations in a C program are called C operators.

TYPES OF OPERATOR-

A) Arthimatic operator.
B) Relational operator.
C) Logical operator.
D) Bitwise operator.
E) Assignment operator.
F) Conditional operator.

A) ARTHIMETIC OPERATOR-

The Arithmetic operators perform Arithmetic operations . The arithmetic operator can operate on any built in data types. A list of arithmetic operator and their meaning are given below.


B) RELATIONAL OPERATOR-

Relational operators are used to compare, logical, arithmetic and character expression. The whole expression involving the relation operator then evaluate to an integer. It evaluates to 0 if the condition is false and 1 if it is true. A list of relational operator and their meaning are given below.


C) LOGICAL OPERATOR-

A Logical operator is used to compare or evaluate logical and relational expression. A list of logical operator and their meaning are given below.


D) BITWISE OPERATOR-

These operators perform bit wise logical operations on values. Both operands must be of the same type and width: the resultant value will also be this type and width. A list of bitwise operator and their meaning are given below.


E) ASSIGNMENT OPERATOR-

An Assignment operator is used to form an assignment expression, which assigns the value to an identifier. A list of assignment operator and their meaning are given below.


F) CONDITIONAL OPERATOR-

The conditional expression can be used as shorthand for some if-else statements. Conditional operator is also called as ternary operator. This operator consist of two symbols: the question mark (?) and the colon (:).

SYNTAX -

Identifier = (test expression)? Expression1:
Expression2



SOME IMPORTANT DEFINITION-

OPERATOR PRECEDENCE-
              
If more than one operators are involved in an expression, C language has a predefined rule of priority for the operators. This rule of priority of operators is called operator precedence.

ASSOCIATIVITY OF OPERATOR- 

If two operators of same precedence (priority) is present in an expression, Associativity of operators indicate the order in which they execute.

5- DEFINITION OF SPECIAL CHARACTERS -

Special characters are symbols (single characters or sequences of characters) that have a "special" built-in meaning in the language and typically cannot be used in identifiers.

Escape sequences are methods that the language uses to remove the special meaning from the symbol, enabling it to be used as a normal character, or sequence of characters when this can be done.

ESCAPE SEQUENCE -
































Post a Comment

0 Comments