Advertisements
Advertisements
Question
Assume n = 10; what will be result of n++ and --n;?
Advertisements
Solution
11 and 9 respectively.
the notations like n++ and ++n are used in coding
both n++ and ++n stand for n=n+1 but there is small difference.
if we assume a=10 and n=10 then a<++n is true but a<n++ is false.
for a<++n first n value gets increment by 1 and becomes 11 then the condition is checked.
for a<n++ first the condition is checked and becomes false then n is incremented by 1 and becomes 11.
- -n and n- - also explained in the same way but - - is decrement operator w3here as ++ is increment operator.
APPEARS IN
RELATED QUESTIONS
Which of the following statements is not true?
Which of the following is a valid string literal?
Which of the following is called compile-time operators?
The following constant is of which type?
032
The following constant is of which type?
0XCAFE
Write the following real constant into the exponent form:
7.214
Match the following.
| A | B |
| (a) Modulus | (1) Tokens |
| (b) Separators | (2) Remainder of a division |
| (c) Stream extraction | (3) Punctuators |
| (d) Lexical Units | (4) get from |
Describe the differences between keywords and identifiers?
Is C++ case sensitive? What is meant by the term “case sensitive”?
Differentiate “=” and “==”.
