User Profile

Collapse

Profile Sidebar

Collapse
HSharma1729
HSharma1729
Last Activity: Mar 2 '14, 01:22 PM
Joined: Dec 10 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • HSharma1729
    replied to increment and decrement operator
    in C
    Output will be:
    enter a:3
    enter b:12

    Reason:
    First evaluate the values of prefix operations and then solve the problem by using using that value.
    Here,
    a=3
    b=++a + a++ + a-- + --a
    so, a=3+1-1=3 (1 prefix increment and 1 prefix decrement)
    hence, b=3+3+3+3=12
    a=3+1+1-1-1=3
    See more | Go to post

    Leave a comment:


  • HSharma1729
    replied to regarding increment and decrement operator
    in C
    The simplest trick is to calculate the prefix operators first and then put the net value in the expression.
    1. i++ + i++
    No prefix operator. so, i=5
    exp=5+5=10, i=5+1+1=7
    2. i-- - i++
    No prefix operator. so, i=5
    exp=5-5=0, i=5-1+1=5
    3. ++i - --i
    net value of i= 5+1-1=5
    exp=5-5=0, i=5+1-1=5
    4. --i + i--
    net value of i= 5-1=4
    exp=4+4=8, i=5-1-1=3
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...