हिंदी
तमिलनाडु बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान कक्षा ११

Assume n = 10; what will be result of n++ and --n;? - Computer Science

Advertisements
Advertisements

प्रश्न

Assume n = 10; what will be result of n++ and --n;?

टिप्पणी लिखिए

उत्तर

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.

shaalaa.com
Lexical Units (Tokens)
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 9: Introduction to C++ - Evaluation - Section - B [पृष्ठ १३१]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 11 TN Board
अध्याय 9 Introduction to C++
Evaluation - Section - B | Q 5. | पृष्ठ १३१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×