Found 27104 Articles for Server Side Programming

What are Boolean Literals in C++?

Daniol Thomas
Updated on 10-Feb-2020 12:10:57

285 Views

Boolean literals are literals that have either the meaning true or false. There are only two Boolean literals in C++: true and false. These literals are of type bool. You can use them as −Example#include using namespace std; int main() {    bool my_bool = true;    if(my_bool) {       cout

Tokens vs Identifiers vs Keywords in C++

Krantik Chavan
Updated on 30-Jul-2019 22:30:21

651 Views

A token is the smallest element of a C++ program that is meaningful to the compiler. The C++ parser recognizes these kinds of tokens: identifiers, keywords, literals, operators, punctuators, and other separators. A stream of these tokens makes up a translation unit. Tokens are usually separated by white space.The parser recognizes keywords, identifiers, literals, operators, and punctuators. Preprocessing tokens(like #include, #define, #if_def, etc.) are used in the preprocessing phases to generate the token stream passed to the compiler. The preprocessing token categories are header names, identifiers, preprocessing numbers, character literals, string literals, etc. that do not match one of the ... Read More

What do you mean by C++ Tokens?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:21

2K+ Views

A token is the smallest element of a C++ program that is meaningful to the compiler. The C++ parser recognizes these kinds of tokens: identifiers, keywords, literals, operators, punctuators, and other separators. A stream of these tokens makes up a translation unit. Tokens are usually separated by white space.The parser recognizes keywords, identifiers, literals, operators, and punctuators. Preprocessing tokens(like #include, #define, #if_def, etc.) are used in the preprocessing phases to generate the token stream passed to the compiler. The preprocessing token categories are header names, identifiers, preprocessing numbers, character literals, string literals, etc. that do not match one of the ... Read More

Can a C++ variable be both const and volatile?

Smita Kapse
Updated on 30-Jul-2019 22:30:21

2K+ Views

Yes a C++ variable be both const and volatile. It is used in situations like a read-only hardware register, or an output of another thread. Volatile means it may be changed by something external to the current thread and Const means that you do not write to it (in that program that is using the const declaration).

What is the difference between #define and const Keyword in C++?

Anvi Jain
Updated on 30-Jul-2019 22:30:21

262 Views

The #define directive is a preprocessor directive; the preprocessor replaces those macros by their body before the compiler even sees it. Think of it as an automatic search and replace of your source code.A const variable declaration declares an actual variable in the language, which you can use like a real variable: take its address, pass it around, cast it, convert it, etc.Without compiler optimizations, there is a hidden cost of memory allocation associated with both of these in different cases. But with proper optimizations they are more or less the same. Also, preprocessor macros don't have any scope, while ... Read More

What is the const Keyword in C++?

Nitya Raut
Updated on 10-Feb-2020 11:15:04

402 Views

We use the const qualifier to declare a variable as constant. That means that we cannot change the value once the variable has been initialized. Using const has a very big benefit. For example, if you have a constant value like the value of PI, you wouldn't like any part of the program to modify that value. So you should declare that as a const.Objects declared with const-qualified types may be placed in read-only memory by the compiler, and if the address of a const object is never taken in a program, it may not be stored at all.  For ... Read More

What is the #define Preprocessor in C++?

Jennifer Nicholas
Updated on 18-Jun-2020 13:05:52

477 Views

The #define creates a macro, which is the association of an identifier or parameterized identifier with a token string. After the macro is defined, the compiler can substitute the token string for each occurrence of the identifier in the source file.#define identifier token-stringThis is how the preprocessor is used. The #define directive causes the compiler to substitute token-string for each occurrence of identifier in the source file. The identifier is replaced only when it forms a token. That is, identifier is not replaced if it appears in a comment, in a string, or as part of a longer identifier.example#include #define ... Read More

How to indent multiple if...else statements in Python?

Malhar Lathkar
Updated on 26-Feb-2020 11:11:26

2K+ Views

Use of indented blocks is an important feature of Python. Indent level of the block is more than previous statements. Hence, if multiple if statements are present in a program in nested fashion, each subsequent indented block will have increasing level of indent.if expr1==True:     if expr2==True:         stmt1     else:          if expr3==True:         stmt2 else:     if expr3==True:        stmt3     else:        stmt4

How to indent an if...else statement in Python?

Malhar Lathkar
Updated on 18-Jun-2020 13:04:11

654 Views

One of the characteristic features of Python is use of uniform indent to denote a block of statements. A block is initiated by − symbol As soon as − symbol is typed and enter pressed, any Python aware editor will take cursor to next line with increased indent. All lines entered subsequently will follow same level of indent. To signal end of block, indent level must be reduced by pressing backspace.Using above procedure give − after if statement and write statements in true block. Then dedent by backspace and write else − In another block of increased indent enter statements ... Read More

Can we use pass statement in a Python if clause?

Malhar Lathkar
Updated on 18-Jun-2020 13:01:38

89 Views

In Python, pass keyword is a dummy statement. It is used where a statement is necessary to fulfill syntax requirement but the actual implementation of processing logic is yet to be finalized. It can be used in if as well as else blockif expr==True:    pass else:    pass

Advertisements