Tokens in C++
There are different types of tokens in C++ like Identifiers, Operators and Keywords, Constants. Identifiers:
According to homework helper identifiers are used in naming the classes, methods, arrays, etc in a program. The identifiers are programmer created tokens.
Rules for naming identifiers :
- Only alphabet character, digits or underscore. For example - ‘a’, ‘_a’. - It should not start with a digit but can end with digit. For example – ‘a1’. - It should not be a keyword. For example – ‘int’ (not allowed). For example: Variable like ‘var’.
Keywords are words which convey a special meaning to the compiler. According to free homework answers service they are reserved for special purpose and cannot be used as identifiers. They cannot be used as class name, variable name, and method name. For example: There are various keywords like ‘for’, ‘finally’, ‘throw’, etc.
Operator specifies the operation to be performed by a mathematical or logical operation. They are used in a program to operate data and variables. Different categories of operators are as follows:
According to chemistry homework help service they are used to make mathematical expressions working in algebra. Java provides the fundamental arithmetic operators (‘+’ Addition, ‘-’ Subtraction, ‘*’ Multiplication, ‘/’ Division, ‘%’ modulus or remainder).
Logical operator is used where we have to form a compound condition combining two or more relations. Java provides logical operators like ‘|| ’(Logical OR), ‘&&’ (Logical AND), ‘!’ (Logical NOT).
First C++ Program
Here is a simple C++ program to learn the instructions of C++.
using namespace std;
cout<<“Welcome to Student Learning Point”;
return 0; }
• This simple program is to print the message “Welcome to Student Learning Point” on the Display.
• In the first line of program there is “#include<iostream>” which is called preprocessor directive. It is the header file which contains input/output statements which we can use by declaring it.
• ‘using namespace std;’ tells the compiler to use the std namespace.
• Every program must contain a main() function. The execution of a program always starts with the main function. The return type of the function is ‘int’.
• ‘cout<<’ will print the content present in the brackets as it is on the output screen.
• ‘return 0;’ will terminate the main( )function and cause it to return the value 0 to the calling process.
• The program must be saved with “.cpp” extension. For example “FirstProgram.cpp”.