Character Set :-
possible character can be used in C language statements are called character set.
Letters : Both uppercase and lowercase a-z, A-Z can be used.
Numbers : 0-9
Special Symbols : " ", ' ', (), [ ] , { }, *, & etc.
Tokens :-
To prepare a complete C statement we require words, symbols, numbers etc. are called as tokens.
Types of tokens :-
Identifier : These are user defined words apart from keywords.
Constant : It is a value which is fixed and can't be change during the program execution.
In C we can have Integer constant, real constant etc.,
There two categories of constant:
1. Numeric
2. Character
In NUMERIC there are two types of constants,
1. Integer
2. Real
INTEGER constant are round numbers without decimal part like 5,8,3 etc.
REAL constants are numbers with decimal part like 3.1, 6.8 etc.
In CHARACTER there are two types of constants,
1. Single
2. String
Single character constant may be a one letter / numeric digit / symbols enclosed in single quotation mark (' '). Ex: 'a', '2', '+'
String : Group of characters enclosed into a double quotation marks is called as string like "Language", "KA-37J-9291"
Operators: C provides rich set of operators of different types like arithmetic, relational etc.,
Eg: +, -, *, /
Special Symbols :- These symbols are used to indicate blocks, arrays and functions.
Eg: (), [ ] , { }
Constants in C : In C, while initializing values to a variables the following conventions should be used,
Data types :
REAL : To represent real number keywords are float and double.
Variables :
Variables are not constants. Rules for writing variable name :
1. It should starts with a letter
2. It can contain numbers and special symbol _ (Underscore) except in first place and spaces are not allowed.
3. Variable names should not be same as keyword names
4. Variables name can be upto 31 characters.
Ex : radius, area, length, breadth, width, height, a, average etc.,
Declaring variables :-
Syntax :
Type var-name1, var-name2, ...;
Ex:
int a,b,c;
int r;
float area;
possible character can be used in C language statements are called character set.
Letters : Both uppercase and lowercase a-z, A-Z can be used.
Numbers : 0-9
Special Symbols : " ", ' ', (), [ ] , { }, *, & etc.
Tokens :-
To prepare a complete C statement we require words, symbols, numbers etc. are called as tokens.
Types of tokens :-
Keyword : These are reserved words of the language where the meaning and syntax (the method of writing command) is predefined in the language. Following are the list of Keywords present in C,
auto
break
case
char
const
continue
|
for
goto
if
int
long
register
|
default
do
double
else
enum
extern
|
float
void
volatile
return
short
while
|
signed
sizeof
static
struct
switch
typedef
union
unsigned
|
Constant : It is a value which is fixed and can't be change during the program execution.
In C we can have Integer constant, real constant etc.,
There two categories of constant:
1. Numeric
2. Character
In NUMERIC there are two types of constants,
1. Integer
2. Real
INTEGER constant are round numbers without decimal part like 5,8,3 etc.
REAL constants are numbers with decimal part like 3.1, 6.8 etc.
In CHARACTER there are two types of constants,
1. Single
2. String
Single character constant may be a one letter / numeric digit / symbols enclosed in single quotation mark (' '). Ex: 'a', '2', '+'
String : Group of characters enclosed into a double quotation marks is called as string like "Language", "KA-37J-9291"
Operators: C provides rich set of operators of different types like arithmetic, relational etc.,
Eg: +, -, *, /
Special Symbols :- These symbols are used to indicate blocks, arrays and functions.
Eg: (), [ ] , { }
Constants in C : In C, while initializing values to a variables the following conventions should be used,
constant | Description |
123 | Represents integer. Use any integer value without decimal part. |
123U | Represents unsigned integer. |
123L | Represents signed long integer value. |
123UL | Represents unsigned long integer value. |
'X' | Represents a single character. |
"XYZ" | R epresents string. |
1.23 | Represents a double floating point value. |
1.23F | Represents particulary Float point constant. |
1.23L | Represents a long double floating point constant |
Data types :
Data types are used to indicate the type of value required and also gives details about how much memory is required to store the required value.
In Integer we can have both Signed and Unsigned. Where signed integer are used to have both positive and negative numbers. Keywords used to represent Signed integers are as follows,
- short int
- int
- long int
- char
Unsigned integers are used to represent only positive numbers. Variables require only positive numbers can select unsigned integer data type. The negative side range will be added to positive side range hence unsigned integer range will get doubled starting from 0. For example signed short integer range is -128 to +127. -128 is added to +127 and it becomes 0 to 255 in unsigned short integer.Prefix a keyword unsigned to signed integer keywords to make them unsigned integer like,
- unsigned short int
- unsigned int
- unsigned long int
- unsigned char
REAL : To represent real number keywords are float and double.
Variables :
Variables are not constants. Rules for writing variable name :
1. It should starts with a letter
2. It can contain numbers and special symbol _ (Underscore) except in first place and spaces are not allowed.
3. Variable names should not be same as keyword names
4. Variables name can be upto 31 characters.
Ex : radius, area, length, breadth, width, height, a, average etc.,
Declaring variables :-
Syntax :
Type var-name1, var-name2, ...;
Ex:
int a,b,c;
int r;
float area;
Excellent Programming
ReplyDeleteThank you
Deleteit is good
ReplyDeleteThank you
ReplyDelete