C-Tokens:
the c-language program can contain the individual units called c-tokens.
- keywords
- Identifiers
- constants
- strings
- operators
- special symbols
keywords:
- keywords also called as reserved words .
- keyword is a basic building block of c language.
- c-language has 32 keywords and each keyword has fixed meaning.
- keywords must be in lower case letters.
Identifiers:
- Identifiers are the names given to various program elements such as variables, functions,arrays,etc.
Rules:
- 1st character can be alphabet or '_'
- Identifier cannot be a reserved word.
- it cannot support blank spaces.
- identifiers are case sensitive.
- they can be max of 32 characters any excess characters are ignore.
Constants
- It is a fixed value that value cannot change during execution of the program.
In c-language we have memory constants and Symbolic constants
- memory constants:memory constants can be defined by using constkeyword.
Syntax: const datatype const-name = value;
example: const float pi = 3.14;
example: const float pi = 3.14;
- Symbolic constants: It can be defined by using preprocessor directive (# define).
Syntax: #define symbolic-name const-value
example: #define PI 3.14
example: #define PI 3.14
String Declaration:
- there is no String datatype in c language.
- so we have to use char array to declare a string.
char a[20];
- here array a can hold max of 19 characters and string leaves one location for \0.
variables:
- variable is a memory location name it store a value that value change during execution of program.
int a=10;
a=a+5;
a=a-6;
- value of a is finally 9.
declaration statement:
- creating a variable and allocating the memory is known as declaration.
int a,b,c;syntax: datatype var-name1,var-name2...........;
Initializing variable:
- this can be done by using assignment operator(=),the variable can initialize while declaration itself.
example: int a=30;float b=30.33;
You can also refer
---------------------------------------------------------------------------------------------------------
No comments:
Post a Comment