answersLogoWhite

0


Best Answer

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).

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the return type of and operator in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the default return type in C and C plus plus?

No. There is no default return type for functions, it must be explicitly specified in both the function declaration and in the definition. To specify no return value, return void. To return a variant type, return void* (pointer to void). Otherwise return the exact type.


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.


C plus plus program using operator overloading?

class foo { private: int m_data; public: foo (int data=0): m_data (data) {} foo (const foo& source): m_data (source.m_data) {} foo (foo& source): m_data (std::move (source.m_data)) {} // operator overloads: assign foo& operator= (const int source) { m_data = source; return *this; } foo& operator= (const foo& source) { m_data = source.m_data; return *this; } foo& operator= (foo& source) { m_data = std::move (source.m_data); return this; } // compound operator overloads: increment and assign foo& operator+= (const foo& rhs) { m_data += rhs.m_data; return *this; } foo& operator+= (const int rhs) { m_data += rhs; return *this; } };


Why the return type of all the function by default is int in c?

Because int is the most common data-type in C. Don't rely on this though, always specify the return type explicitly.


How many types of function in C?

Well, it depends on what you mean by the type of a function. There are user defined functions and library functions.

Related questions

Which is dummy operator in c?

In C, the sizeof operator can be considered a dummy operator because it does not perform any operations on the data but simply returns the size in bytes of a variable or a data type.


Can an instance of class C be obtained as a result of operator overloading where NONE of the operands in the operator functions are of type C?

Yes, it is possible to do this. Consider the following example that returns an instance of class C from the sum of two instances of class A. #include <iostream> class A { public: A(int i=0):m_data(i){} int m_data; }; class C { public: C(int i=0):m_data(i){} int m_data; }; C operator+(const A&a,const A&b) { return(C(a.m_data+b.m_data)); } int main( void ) { A a(5); A b(6); C c=a+b; std::cout<<"c.m_data="<<c.m_data<<std::endl; return(0); }


How unary minus can be overload in c plus plus?

type operator- ();


What is the default return type in C and C plus plus?

No. There is no default return type for functions, it must be explicitly specified in both the function declaration and in the definition. To specify no return value, return void. To return a variant type, return void* (pointer to void). Otherwise return the exact type.


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.


C plus plus program using operator overloading?

class foo { private: int m_data; public: foo (int data=0): m_data (data) {} foo (const foo& source): m_data (source.m_data) {} foo (foo& source): m_data (std::move (source.m_data)) {} // operator overloads: assign foo& operator= (const int source) { m_data = source; return *this; } foo& operator= (const foo& source) { m_data = source.m_data; return *this; } foo& operator= (foo& source) { m_data = std::move (source.m_data); return this; } // compound operator overloads: increment and assign foo& operator+= (const foo& rhs) { m_data += rhs.m_data; return *this; } foo& operator+= (const int rhs) { m_data += rhs; return *this; } };


How the predecrementer and postdecrementer are taken care of while declaring operator overloading?

When you overload the -- and ++ operators in C++, if you want the pre version, aka --var, simply declare the function without an argument; whereas if you want the post version, aka var--, simply declare the function with an argument of type int. class abc { public: abc& operator++(); // pre-increment form abc& operator++(int); // post-increment form ... }; abc::operator++() { ... pre increment stuff return *this; } abc::operator++(int) { ... post increment stuff return *this; }


What are the basic operator in turbo c?

+ += - -= * *= / /= % %= = == != <= >= & && | ^ ~ << <<= >> >>= , [] () are the basic operator in TURBO C


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++


Why the return type of all the function by default is int in c?

Because int is the most common data-type in C. Don't rely on this though, always specify the return type explicitly.


What are the valid type of data that the main can return in c language?

Type 'int'


Use of scope resolution operator in C programming?

:: operator can not be used in C.