Awesome q2a theme
0 votes
17 views
Can anyone explain what are the different value i can get when the expression is evaluated?

i=i++;
in Programming by (114 points) | 17 views

1 Answer

0 votes

Let i = 5

Definition of post increment is – Use the value first and then change it.

so here i = i++; will first use the value 5, after that i value of i will get changed to 6. But the previous value of i=5 will overrite the value 6. Hence we will get i=5.

But if we use the statement

j = i++;

Here i’s  previous value 5 gets stored in the variable j after the increement of i to 6. Hence j=5 and i=6

by (356 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users May 2020
  1. Kushagra गुप्ता

    97 Points

  2. praveen modala

    15 Points

  3. ramcharantej_24

    15 Points

  4. abhishek tiwary

    12 Points

  5. srestha

    12 Points

  6. Dtiwari

    9 Points

  7. Shivateja MST

    8 Points

  8. ankitgupta.1729

    8 Points

  9. Rashimdixit

    7 Points

  10. Bhavya1902

    7 Points

7,376 questions
1,741 answers
10,682 comments
90,352 users