answersLogoWhite

0

What else can I help you with?

Related Questions

What is the function of plus sign?

The "plus sign" (+) is an operator that, by default, takes the left and right operands as parameters, and returns the sum of both operands as the return value.


What is operand in c plus plus?

An operand is the value that is being operated upon by an operator. For instance, the C++ increment operator (++) is a unary operator, which means it has only one operand, the variable that we wish to increment. This in the expression x++, x is the operand. The addition operator (+) is a binary operator and therefore has two operands. Thus in the expression x + y, x and y are the operands.


What is the definition for and?

Conjunction Used to connect words of the same part of speech, clauses, or sentences that are to be taken jointly: "bread and butter". Noun A Boolean operator that gives the value one if and only if all the operands are one and otherwise has a value of zero.


What is the difference between the assignment operator and the equals operator?

The quality operator and the assignment operator are binary operators; they have two operands, one on either side of the operator. The equality operator is a Boolean operator which compares the two operands, returning true if they have the same logical state, otherwise false. E.g., x==y returns true if x and y have the same logical state, otherwise false. The operator is commutative, such that x==y is the same as y==x. The assignment operator sets the value of the left operand to that of the right operand, such that they both have the same logical state. After assignment, the left operand is returned. E.g., x=y returns x while y=x returns y. After the assignment, x==y must be true.


Which operand should be passed in the binary overloaded operator function as a second operand?

The right-hand operand; the r-value of the operator. Unary operators have one operand while tertiary operators have three operands. All binary operators have two operands, the l-value and the r-value. The l-value is the operand to the left of the operator while the r-value is the operand to the right of the operator. Thus, in the expression x + y, x is the l-value while y is the r-value. When overloading binary operators in a class, you need only specify the r-value. The l-value is the instance of the class to which the operator applies and therefore does not need to be specified. For instance: class MyClass { public: MyClass(int data=0):m_data(data){} // default constructor int operator+ (const int rhs) const {return(m_data+rhs);} private: int m_data; }; While this allows you to return the sum of your class instance and an integer, it does not allow you to return the sum of an integer and an instance of your class. For example: MyClass obj(5); int x = 10; int y = obj + x; // OK! y is 15. int z = x + obj; // Compiler error! No operator exists that accepts an r-value of type MyClass. To fix this error and allow for two-way addition, you must declare a binary operator overload outside of the class. You cannot do it inside the class because the l-value is an int, not an instance of MyClass. The external overload requires two parameters, the l-value and the r-value of the operator: int operator+(const int lhs,const MyClass& rhs) {return(rhs+lhs);} Note that the implementation simply reverses the operands. This is functionally equivalent to making the following explicit call: return(rhs.operator+(lhs)); Note also that since MyClass::operator+ is a public operator of MyClass, this overload does not need to be declared a friend of MyClass (a common misconception). However, the overload must be declared in the same file where the class is declared since it is only of relevance to MyClass but should be made available wherever MyClass is accessible.


What operator is best to determine whether x contains a value in the range of 10 through 57?

Not to answer, but to clarify this question this would be operators such as *and* *or* *==* *not*


What are the rules for negative and positive integers multiplying and dividing?

The absolute value (that is the numerical value ignoring the sign) of the result is the operation done on the absolute value of the operands. If the signs of the operands are the same the result will be positive; otherwise the signs of the operands are different and the result will be negative. eg -2 × 5: the operands are of opposite signs (one positive, one negative), so the result will be negative and 2 × 5 = 10, thus -2 × 5 = -10; eg -2 × -5: the operands are of the same sign (both negative), so the result will be positive, and 2 × 5 = 10, thus -2 × -5 = 10; eg 10 ÷ -5; the operands are of opposite signs, so the result will be negative and 10 ÷ 5 = 2, thus 10 ÷ -5 = -2.


Which value is modified by an operator?

The value of the variable which is on the left side of the assignment operator. Example: a = 2


Why to take two arguments in binary operator overloading using friend function?

Binary operators require two operands (l-value and r-value) and therefore require two arguments when overloading via external functions. When overloading class member operators, the l-value is the class instance itself (the implicit this pointer), therefore only the r-value need be given as an argument.


What is the return type of and operator in c?

There are two AND operators in C, logical AND (&&) and bitwise AND (&). The return type for logical AND is always bool, however logical AND only works when both operands can be implicitly cast to bool. The value 0 is always regarded as being false while all non-zero values are regarded as being true. The return type for bitwise AND is that of the largest of its two operands. For instance, the return type of int & char is int (same as the l-value) while the return type of char & int is also int (same as the r-value).


What is the difference between you equals 10 and you equals equals 10 in c language?

The = operator is the assignment operator. The == operator is the equality or equals operator. The = operator is the assignment operator. We use it to assign a value (the right hand operand) to an object (the left hand operand). The value must be of the same type as the object unless the value can implicitly convert to the object's type. If not, we must explicitly cast the value to the appropriate type. The operator evaluates to the value of the object after assignment, thus creating a temporary value that can be used in other expressions. Examples: int you; you = 10; // assign the value 10 to the object named 'you' int me, you; me = 10; you = 10; Note that the second example can also be written: int me, you; me = you = 10; This is because the expression 'you = 10' evaluates to the temporary value 10 (the value of 'you' after assignment) which we then assign to 'me'. Operators are evaluated according to operator precedence, and assignment 'chains' like this are always evaluated from right to left. The == operator is the equality or equals operator. We use it to determine if two object's have the same value. If so, the expression evaluates true, otherwise false. Operators that evaluate true or false are known as Boolean operators (functions that return true or false are known as predicates). Typically we use the == operator in conditional expressions: if (a == b) { // code to execute when the value of a is equal to the value of b } else { // code to execute when the value of a is not equal to the value of b } while (a == b) { // This code will loop repeatedly so long as a is equal to b at the beginning of each iteration } The == operator is one of six Boolean operators that can be used to compare object values: == : equal != : not equal < : less than <= : less than or equal > : greater than >= : greater than or equal


Which operator is called ternary operator?

A ternary operator is an operator that requires three operands, as opposed to a binary operator that requires two operands and a unary operator that requires just one operand. C++ has just one ternary operator, the conditional ternary operator: <boolean expression> ? <expression #1> : <expression #2>; If the boolean expression evaluates true, the first expression is evaluated, otherwise the second expression is evaluated. A typical usage of this operator is to return the larger (or smaller) of two values of type T: template<typename T> T max (T a, T b) {return a<b ? b : a}; template<typename T> T min (T a, T b) {return a<b ? a : b}; These are really nothing more than notational shorthand for the following: template<typename T> T max (T a, T b) {if (a<b) return b; else return a; }; template<typename T> T min (T a, T b) {if (a<b) return a; else return b;}; However, because ternary expressions are evaluated, the return value of the expression can be used in more complex expressions: int a=42, b=0; // ... int c = ((a>b ? a : b) = 1); In the above expression, whichever is the larger of a and b will be assigned the value 1 which will also be assigned to c. Thus a and c become 1 while b remains 0.