Computer Science, asked by Artybabe, 1 year ago

Split the tokens in the c plus plus statement, int num=5

Answers

Answered by Anonymous
0
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:

auto const double float int short struct unsigned
break continue else for long signed switch void
case default enum goto register sizeof typedef volatile
char do extern if return static union while
There are another 30 reserved words that were not in C, are therefore new to C++,
and here they are:

asm dynamic_cast namespace reinterpret_cast try
bool explicit new static_cast typeid
catch false operator template typename
class friend private this using
const_cast inline public throw virtual
delete mutable protected true wchar_t
The following 11 C++ reserved words are not essential when the standard ASCII character set is being used, but they have been added to provide more readable alternatives for some of the C++ operators, and also to facilitate programming with character sets that lack characters needed by C++.

and bitand compl not_eq or_eq xor_eq
and_eq bitor not or xor
Identifiers
Identifiers refers to the name of variables, functions, arrays, classes, etc. created by the user. Identifiers are the fundamental requirement of any language.

Identifier naming conventions

Only alphabetic characters, digits and underscores are permitted.
First letter must be an alphabet or underscore (_).
Identifiers are case sensitive.
Reserved keywords can not be used as an identifier's name.
Constants
Constants refers to fixed values that do not change during the execution of a program.

Declaration of a constant :
const [data_type] [constant_name]=[value];
Consider the example

#include
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 :"< cout<<"choice :"< cout<<"title :"< cout<<"temp :"< return 0;
}
Output

max_length :100
choice :Y
title :www.includehelp.com
temp :12.34
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 requires all the variables to be defined in the beginning of scope.

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.

Syntax to declare a variable :
[data_type] [variable_name];
Consider the example

#include

int main()
{
int a,b;
cout<<" Enter first number :";
cin>>a;
cout<<" Enter second number:";
cin>>b;

int sum; // declaration
/*this type of declaration will not allow in C*/
sum=a+b;
cout<<" Sum is : "< return 0;
}
Output

Enter first number :55
Enter second number:15
Sum is : 70

Aryamohanan23: Dont copy paste unrelevent things..specify the answer.
Anonymous: Is that wrong
Aryamohanan23: check what is the question is?
Aryamohanan23: where you split into tokens int num=5
Answered by Aryamohanan23
4
The tokens are,
1     int    (Keyword)
2.    num    ( identifier)
3.    =    (Special Symbols)
4.   5      (Integer constants)



hope this help you

Artybabe: thnx
Aryamohanan23: plz mark as brainlist
Artybabe: I did
Aryamohanan23: if you have any doubt regarding the computer science ask me...I'm a software engineer
Artybabe: Ok i followed u. I hv one mpre doubt. Wht is the binary form of 14B. C
Aryamohanan23: 1 0100 1011.11
Similar questions