CPP Language / Tokens, Identifiers & Keywords
Tokens in CPP Language
Each and every smallest individual unit in a CPP program are known as CPP tokens and considered as basic buildings blocks of CPP language.CPP tokens are of 6 types. They were
|
Tokens Type
|
Example
|
|
Keywords
|
These are the predefined words used for a particular purpose in the program.
Example: For, int, while e.t.c
|
|
Identifiers
|
It is a name used to identify a variable / function / any other thing defined by user and it starts with a letter A to Z, a to z, or an underscore '_' followed by letters, and digits (0 to 9) and punctuation characters not are allowed (Like @, $, and %) within identifiers. Identifiers are case sensitive i.e "SUM", "sum" are treated differently.
main, total e.t.c
|
|
Constants
|
Constants are fixed values they dont change during the execution of a program.
Constants Types in C++
Integer constants –store int data type values.
const int a = 10;
Floating constants – store float data type values.
const float b = 20.1234;
Character constants – store character data type value.
const char c = ‘w’;
String constants – store collection of character data type values.
const char d[] = ‘‘Wisdom Materials;
|
|
Strings
|
“sum”, “average”,”total”
|
|
Special symbols
|
Brackets[], Parentheses(), Braces{},
comma (, ), semi colon, asterick (*),
assignment operator, pre processor(#) |
|
Operators
|
Operator is symbol used to perform operation.
Types of Operators:
Arithmetic(+, -, *, /, %),
Relational(==, !=, >, <, >=,<=),
Logical(&&, ||, !),
Assignment(=, +=, -=, *=,/=, %=, <<=,>>=, &=, ^=,|=),
Conditional(?:),
Bitwise,Ternary(<<, !=, >>, ~,&, ^, |)
|
keywords List in CPP language
| do |
for |
float |
continue |
| void |
else |
if |
switch |
| struct |
enum |
register |
char |
| typedef |
static |
return |
default |
| const |
int |
short |
volatile |
| while |
double |
break |
signed |
| union |
long |
sizeof |
unsigned |
| extern |
goto |
auto |
case |
| typeid |
false |
catch |
new |
| this |
delete |
try |
explicit |
| export |
typename |
using |
inline |
| asm |
namespace |
class |
throw |
| private |
protected |
public |
true |
| static_cast |
template |
const_cast |
operator |
| reinterpret_cast |
dynamic_cast |
mutable |
bool |
| friend |
virtual |
wchar_t |
|
|