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

in Programming by (69 points) | 12 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 (118 points)
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Oct 2019

    410 Points

  2. Satbir

    317 Points

  3. Rudr Pawan

    163 Points

  4. srestha

    136 Points

  5. Mk Utkarsh

    127 Points

  6. Debapaul

    94 Points

  7. chandrikabhuyan8

    83 Points

  8. Shaik Masthan

    79 Points

  9. Verma Ashish

    77 Points

  10. !KARAN

    74 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 450.
1,680 questions
1,089 answers
89,591 users