“C” Tokens
Individual words and punctuation marks are characters. In a “C” program the smallest individual units are known as “C” tokens. It has 6types of token‟s
Keyword is an predefined word ,Which is an already defined by the C-Develphers
Ex:int ,float,char,if etc...
C-Language contains 32 Keywords
Constants
Constant is an identifier whose value can't be changed.
Ex:int x=10;
Here 10 is a Constant
x is a Variable
int is a Datatype
These constants are classified into 2 types
- Keywords
- Identifiers
- Constants
- Variables
- Data types
- Type def
Keyword is an predefined word ,Which is an already defined by the C-Develphers
Ex:int ,float,char,if etc...
C-Language contains 32 Keywords
Constants
Constant is an identifier whose value can't be changed.
Ex:int x=10;
Here 10 is a Constant
x is a Variable
int is a Datatype
These constants are classified into 2 types
- Numerical Constants
- Character Constants
- Numerical Constants: Numerical Constants menans Numbers these are classified into 2 types
- Integer Constants
- Real Constants
- Character Constants Character constants menas Characters these are classified into 2 types
- Single character constants
- String character constants
Ex:int x=10;
int y=-24;
Real Constants Real constants means floating values
Ex:float x=1.0;
Ex:char ch='a'
char ch='@';
char ch='4';
String character Constants Group of character or symblos or numbers enclosed with double quotation
Ex:char ch[20]="varshini";
Variable
Variable
Variable is an identifier whose value can be changed or which holds the data
Ex:int x=12;
x=20;
Variable Declaration Rules:Initilization: It menas initilize the some value to the variable
Ex:int x=12; here 12 is initilize to the xDeclaration In the Declaration no value initilize to the variable
Ex:int x;Assignment In the assignment assign the value to the variable or assign variable to the variable
Ex:int x;
x=12;(value to variable)
int y;
y=x;(variable to variable)
Variable is an identifier whose value can be changed or which holds the data
Ex:int x=12;
x=20;
Variable Declaration Rules:
- Variable name must be start with alphabet or underscore or doller symbol Ex:int age=12;
- The max length of the variable name is upto 32 characcters
- If variable name contains morethan one word ,The second word onwords first letter should be uppercase letter Ex:int studentAge=12;
- No spaces are allowed at the middle of the variable declaration Ex:int student Age=24; (Invalid)
- If variable value contains constant value that variable name must be uppercase Ex: const float PI=3.14
- If constant variablename contains morethan one word ,It should be separated with underscore Ex:const int STUDENT_AGE=24;
- All keywords are lowercase letters
- We should not take keyword as a variable name Ex: int if=12 (invalid) Here if is a keyword
int _age=24;
int $age=45;
const int AGE=24;
- Initilization
- Declaration
- Assignment
Ex:int x=12; here 12 is initilize to the x
Ex:int x;
Ex:int x;
x=12;(value to variable)
int y;
y=x;(variable to variable)
Datatypes
Datatypes are used to identify the type of data or which allocates the sufficient memory space for the varables. These Datatypes are classified into following types:Primitive Datatypes: Primitive datatypes are used to store the single value at a time
Ex:int x=12;
int y=12,13;(invalid) These Primitive datatypes are classified into following typesDerived Datatypes: These are used to store the morethan one value similar type
Ex:Arrays--- int marks[]={12,12,12,12,12,12}
Userdefined Datatypes: These are used to store the morethan one value dissimilar type
Ex:structure,union
Type def : Defined as type definition by using typedef we can create new datatype. Typedef type data _ame;
Type ---- datatype
Dataname---- Name of that type
- Primitive Datatypes
- Derived Datatypes
- Userdefined Datatypes
Ex:int x=12;
int y=12,13;(invalid) These Primitive datatypes are classified into following types
- Integer datatype
- Floating point datatypes
- Character datatypes
- Void Datatypes
Ex:Arrays--- int marks[]={12,12,12,12,12,12}
Ex:structure,union
Type ---- datatype
Dataname---- Name of that type
No comments:
Post a Comment