CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES DETAILS
    Question :
    void main()
    {
    int i=20;j=35,x,y;
    x= y++ + x++;
    y= ++y + ++x;
    printf(" %d %d" , x,y);
    }
    /* please tell me the value of x and y at each and every moment. i dont need the answer but the explanation of the anamolus behavior of increment expression.*/


    Posted by: manish on 7/9/2008

    Contact manish Contact manish
    Category Languages Interview Questions
    Rating (0.4) By 887 users
    Added on 7/9/2008
    Views 2116
    Rate it!
    Answers:

    x=1702 y=2560



    Posted by: logesh    

    Contact logesh Contact logesh

    First i explain how the incremental operator works
    Y++ means increase the value of y by one. the value of y is incremented by one after the first iteration.

    ++Y means the value of y is first incremented before iteration and value of y is incremented and then the expression evaluates.

    In the above expression the result is :

    No value is assigned for x & y so when we declare the variables without assigning the values default values may be present so based on that default values the incremental operator works.

    suppose the default values of x & y are 10 & 20 then the expression

    x=y++ + x++
    x=10+20; x=30

    y=++y + ++X
    y=11 + 21; y=32



    Posted by: sarathy C.R    

    Contact sarathy C.R Contact sarathy C.R


    x=y++ + x++
    x=10+20; this gives x=30 but x has been post incremented so calue of x becomes 31.

    y=++y + ++X
    y=21 + 32; y=53
    since x is pre-incremented so value of x becomes 32,and by the same reason y becomes 21 .



    Posted by: krishna    

    Contact krishna Contact krishna

    if we consider as increment of x & y are i & j increment then the value of x=55 & y=59.



    Posted by: md.sayeed    

    Contact md.sayeed Contact md.sayeed

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    Which language should be learn for getting better job?
    View Answer
    How can we print sum of two number without using main function?
    View Answer
    What is a dangling pointer ?
    View Answer
    I am a new programmer in C & can't find <graphics.h> library. can anyone help me with this?
    View Answer
    How type of questions asked in campus interview? please tell me.
    View Answer
    What is the purpose of semicolon in c?
    View Answer
    What is the purpose of the semicolon(;) in languages?
    View Answer
    How to create Crystal Report in Visual Basic 6.0
    View Answer
    In VB which control does not have event?
    View Answer
    What are the differences between malloc() and calloc()?

    What are macros? what are its advantages and disadvantages?
    View Answer
    What is Thread ?
    (VC++)
    What is the difference between Cmutex and Csemaphone?


    View Answer
    What is LPCTSTR? What does LP denote it?

    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Languages Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.03125 Seconds