C Tokens
C Tokens
Following are the C++ tokens : (most of c++ tokens are basically similar to the C
tokens)
Keywords
Identifiers
Constants
Variables
Operators
Keywords
The reserved words of C++ may be conveniently placed into several groups. In the
first group we put those that were also present in the C programming language and
have been carried over into C++. There are 32 of these, and here they are:
There are another 30 reserved words that were not in C, are therefore new to C++,
and here they are:
ADVERTISEMENT
Identifiers
Identifiers refers to the name of variables, functions, arrays, classes, etc. created by
the user. Identifiers are the fundamental requirement of any language.
Constants
Constants refers to fixed values that do not change during the execution of a
program.
Declaration of a constant :
#include <iostream.h>
int main()
{
const int max_length=100; // integer constant
const char choice='Y'; // character constant
const char title[]="www.includehelp.com"; //
string constant
const float temp=12.34; // float constant
cout<<"max_length :"<<max_length<<endl;
cout<<"choice :"<<choice<<endl;
cout<<"title :"<<title<<endl;
cout<<"temp :"<<temp<<endl;
return 0;
}
Output
max_length :100
choice :Y
title :www.includehelp.com
temp :12.34
ADVERTISEMENT
Variable
A variable is a meaningful name of data storage location in computer memory. When
using a variable you refer to memory address of computer.
We know that in C, all variables must be declared before they are used, this is true
with C++.
The main difference in C and C++ with regards to the place of their declaration
in the program...
C++ allows the declaration of a variable anywhere in the scope, this means that
a variable can be declared right at the place of its first use.
[data_type] [variable_name];
#include <iostream.h>
int main()
{
int a,b;
cout<<" Enter first number :";
cin>>a;
cout<<" Enter second number:";
cin>>b;
Output