1.

Which operator works only with integer variables?(a) increment(b) decrement(c) both increment & decrement(d) binary operatorI had been asked this question during an interview.I'd like to ask this question from Increment and Decrement in division Source Files, Classes and Operator Overloading in C++ of C++

Answer»

Right answer is (c) both increment & decrement

Easiest explanation - Because increment and decrement operator increases INCREASING and decreasing VALUES of values and no such things define in strings so cannot be used with strings. Also they cannot be used with floats and DOUBLES because there is no way to fix how MUCH the value should be INCREASED or decreased if increment or decrement operator is applied on such variables. That’s why both these operators only works with integer values.



Discussion

No Comment Found

Related InterviewSolutions