Basics of ‘ C’
Meeta V. Prajapati
Lecturer in Computer Engineering
Computer Deparment
Government Polytechnic, Gandhinagar
Gandhinagar
Learning Objectives
After learning this topic you will be able to understand :
• Character Set
• C Tokens
• Symbolic Constant
• Data types
Character Set
• Character set is a collection of characters that can be used
to write a program of particular language.
• Every language having their own set of characters.
• Character set of c consist of letters, digits, white space and
special symbols
• Letters : A-Z , a-z
• Digits : 0-9
• White spaces : Blank space, tab, new line,form feed,
carriage return
• Special symbols : # + - * / % & ! , . : ; $ ^ | ~ () {} [] <> =
_  “ ‘ ?
C Tokens
• The smallest individual unit of the c program is
known as token.
• Following are the six tokens of c program :
1. Keyword
2. Identifier
3. Constant
4. Operator
5. String
6. Special Symbols
C Tokens
1. Keyword :
• Keywords are predefined words.
• The programmer can not change the meaning of
keyword.
• So they can not be used as a name of variable ,
constant, array , function , structure etc…
2. Identifier :
• Identifiers are user defined words.
• The meaning of identifiers is not predefined.
• User can use identifier as a name of variable, array,
function, structure, etc……
C Tokens
3. Constant :
• Constant means fixed value.
• The value of the constant can not change during the
execution of the program.
4. Operator :
• Operator constructs an expression along with
operands.
• Operator are used for following purpose :
1. Perform mathematical cluculation
2. Perform logical manipulation
3. Determine relationship between operands
4. Assign value of one operands or expression to another
C Tokens
5. String :
• A string is a sequence of characters that is enclosed
between double quotation marks.
• FOR EXAMPLE : “Hello”
6. Special Symbols :
• Following are the special Symbols used in c language :
• # ,+,-,*,/,%,&,| ,~,`,”,:,;,!,?,/,_(),{},[],<>,=,
• The C program consists of different types of tokens.
Symbolic Constant
• The General syntax of defining symbolic constant is given
below :
# define sysmoblic_Constant_Name value
Here,
1. #define is a preprocessor directive which is used to define
symbolic constant.
2. Symbolic_Constant_Name is a name of constant, which
user wants to define.
3. Value of the Constant represents the value , which user
can assign to the constant.
• EXAMPLE :
• # define PI 3.14
Data Types
• Data types is useful in programming language to instruct
compile that which kind of the value can be contained in
the variable.
• Each type of Value required different amount of memory
space. Thus data types also instruct compiler to allocate
amount of memory to hold the value of particular variable.
• Basically C data type are classified into three categories :
1. Primary Data type
2. Derived Data type
3. User Defined Data type
Data Types
• Integer Data Types
Data type Size in Bytes Range Value
short int 1 -128 to 127
unsigned short int 1 0 to 225
int 2 -32768 to 32767
unsigned int 2 0 to 65535
long int 4 -2147483648 to 2147483647
unsigned long int 4 0 to 4294967295
Data Types
• Floating Data types
Data type Size in Bytes Rang Value
Float 4 3.4 E-38 to 3.4E +38
Double 8 1.7 E-308 to1.7 E +308
Long double 10 3.4 E-4932 to 3.4 E
+4932
Data Types
• Character Data types
Data type Size in Bytes Range Value
Char 1 -128 to 127
Unsigned char 1 0 to 225
Thank you…

Cp presentation

  • 1.
    Basics of ‘C’ Meeta V. Prajapati Lecturer in Computer Engineering Computer Deparment Government Polytechnic, Gandhinagar Gandhinagar
  • 2.
    Learning Objectives After learningthis topic you will be able to understand : • Character Set • C Tokens • Symbolic Constant • Data types
  • 3.
    Character Set • Characterset is a collection of characters that can be used to write a program of particular language. • Every language having their own set of characters. • Character set of c consist of letters, digits, white space and special symbols • Letters : A-Z , a-z • Digits : 0-9 • White spaces : Blank space, tab, new line,form feed, carriage return • Special symbols : # + - * / % & ! , . : ; $ ^ | ~ () {} [] <> = _ “ ‘ ?
  • 4.
    C Tokens • Thesmallest individual unit of the c program is known as token. • Following are the six tokens of c program : 1. Keyword 2. Identifier 3. Constant 4. Operator 5. String 6. Special Symbols
  • 5.
    C Tokens 1. Keyword: • Keywords are predefined words. • The programmer can not change the meaning of keyword. • So they can not be used as a name of variable , constant, array , function , structure etc… 2. Identifier : • Identifiers are user defined words. • The meaning of identifiers is not predefined. • User can use identifier as a name of variable, array, function, structure, etc……
  • 6.
    C Tokens 3. Constant: • Constant means fixed value. • The value of the constant can not change during the execution of the program. 4. Operator : • Operator constructs an expression along with operands. • Operator are used for following purpose : 1. Perform mathematical cluculation 2. Perform logical manipulation 3. Determine relationship between operands 4. Assign value of one operands or expression to another
  • 7.
    C Tokens 5. String: • A string is a sequence of characters that is enclosed between double quotation marks. • FOR EXAMPLE : “Hello” 6. Special Symbols : • Following are the special Symbols used in c language : • # ,+,-,*,/,%,&,| ,~,`,”,:,;,!,?,/,_(),{},[],<>,=, • The C program consists of different types of tokens.
  • 8.
    Symbolic Constant • TheGeneral syntax of defining symbolic constant is given below : # define sysmoblic_Constant_Name value Here, 1. #define is a preprocessor directive which is used to define symbolic constant. 2. Symbolic_Constant_Name is a name of constant, which user wants to define. 3. Value of the Constant represents the value , which user can assign to the constant. • EXAMPLE : • # define PI 3.14
  • 9.
    Data Types • Datatypes is useful in programming language to instruct compile that which kind of the value can be contained in the variable. • Each type of Value required different amount of memory space. Thus data types also instruct compiler to allocate amount of memory to hold the value of particular variable. • Basically C data type are classified into three categories : 1. Primary Data type 2. Derived Data type 3. User Defined Data type
  • 10.
    Data Types • IntegerData Types Data type Size in Bytes Range Value short int 1 -128 to 127 unsigned short int 1 0 to 225 int 2 -32768 to 32767 unsigned int 2 0 to 65535 long int 4 -2147483648 to 2147483647 unsigned long int 4 0 to 4294967295
  • 11.
    Data Types • FloatingData types Data type Size in Bytes Rang Value Float 4 3.4 E-38 to 3.4E +38 Double 8 1.7 E-308 to1.7 E +308 Long double 10 3.4 E-4932 to 3.4 E +4932
  • 12.
    Data Types • CharacterData types Data type Size in Bytes Range Value Char 1 -128 to 127 Unsigned char 1 0 to 225
  • 13.