Found 27104 Articles for Server Side Programming

How to prevent loops going into infinite mode in Python?

Gireesha Devara
Updated on 23-Aug-2023 19:02:26

2K+ Views

In python the while loop needs to be controlled by making some provision inside the body of the loop to drive the condition mentioned in the beginning to false. This is usually done by keeping count of iterations. If the while loop condition never evaluates to False, then we will have an infinite loop, which is a loop that never stops automatically, in this case we need to interrupt externally. count=0 while condition: stmt1 stmt2 . . count=count+1 Example Let’s take an example and ... Read More

Unary operators in C++

Rama Giri
Updated on 11-Feb-2020 06:53:36

227 Views

Unary operator are operators that act upon a single operand to produce a new value. The unary operators are as follows −Indirection operator (*) - It operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer.Address-of operator (&) - The unary address-of operator (&) takes the address of its operand. The operand of the address-of operator can be either a function designator or an l-value that designates an object that is not a bit field and is not declared with the register storage-class specifier.Unary plus operator (+) - ... Read More

C++ Operators with Precedence and Associativity

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

3K+ Views

Operator precedence determines the grouping of terms in an expression. The associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. This affects how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator:For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.Here, operators with the highest precedence appear ... Read More

Why does C++ need the scope resolution operator?

Nitya Raut
Updated on 11-Feb-2020 06:44:46

501 Views

The :: (scope resolution) operator is used to get hidden names due to variable scopes so that you can still use them. The scope resolution operator can be used as both unary and binary.You can use the unary scope operator if a namespace scope or global scope name is hidden by an explicit declaration of the same name in a block or class. For example, if you have a global variable of name my_var and a local variable of name my_var, to access global my_var, you'll need to use the scope resolution operator. For example, Example#include   using namespace ... Read More

What is the use of scope resolution operator in C++?

Jennifer Nicholas
Updated on 11-Feb-2020 06:43:03

389 Views

The :: (scope resolution) operator is used to get hidden names due to variable scopes so that you can still use them. The scope resolution operator can be used as both unary and binaryYou can use the single scope operator if a namespace scope or global scope name is hidden by a certain declaration of a similar name during a block or class. For example, if you have a global variable of name my_var and a local variable of name my_var, to access global my_var, you'll need to use the scope resolution operator. For example, Example#include   using namespace ... Read More

Scope resolution operator in C++

Nancy Den
Updated on 11-Feb-2020 06:00:07

6K+ Views

The :: (scope resolution) operator is used to get hidden names due to variable scopes so that you can still use them. The scope resolution operator can be used as both unary and binary. You can use the unary scope operator if a namespace scope or global scope name is hidden by a particular declaration of an equivalent name during a block or class. For example, if you have a global variable of name my_var and a local variable of name my_var, to access global my_var, you'll need to use the scope resolution operator.example#include   using namespace std;   ... Read More

Equality Operators: == and != in C++

Vrundesha Joshi
Updated on 11-Feb-2020 05:58:08

670 Views

The equality operators in C++ are is equal to(==) and is not equal to(!=). They do the task as they are named. The binary equality operators compare their operands for strict equality or inequality. The equality operators, equal to (==) and not equal to (!=), have lower precedence than the relational operators, but they behave similarly. The result type for these operators is bool.The equal-to operator (==) returns true (1) if both operands have the same value; otherwise, it returns false (0). The not-equal-to operator (!=) returns true if the operands do not have the same value; otherwise, it returns ... Read More

Why is sizeof() implemented as an operator in C++?

Nancy Den
Updated on 11-Feb-2020 05:56:32

109 Views

sizeof is not a real operator in C++. It is merely special syntax that inserts a continuing equal to the size of the argument. sizeof doesn’t want or have any runtime support. Sizeof cannot be overloaded because built-in operations, such as incrementing a pointer into an array implicitly depends on it.The C standard specifies that sizeof should be implemented as an operator. In most compilers, the value of sizeof is substituted by a constant equal to it at the compile time itself.example#include using namespace std; int main() {    cout

Difference between Relational operator(==) and std::string::compare() in C++

Rishi Rathor
Updated on 11-Feb-2020 05:52:44

242 Views

There is only one difference between the relational operator == and std::string::compare(). That is the return value. Internally, string::operator==() is using string::compare()Relational operator(==) returns a boolean just signifying whether the 2 strings are equal or not while compare returns an integer that signifies how the strings relate to each other.To elaborate on the use cases, compare() can be useful if you're interested in how the two strings relate to one another (less or greater) when they happen to be different. For example, Example#include using namespace std; int main() {    string s1 = "Tutorials Point";    string s2 = ... Read More

C++ Relational and Equality Operators

Srinivas Gorla
Updated on 11-Feb-2020 05:40:45

2K+ Views

In C Programming, the values hold on in 2 variables will be compared exploitation following operators and relation between them will be determined. These operators are called relational operators. Various C++ relational operators available are-OperatorsDescription>Greater than>=Greater than or equal to

Advertisements