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 COMPUTERS DETAILS
    Question :
    #include<stdio.h>
    void main()
    {
    int y=1,z;
    z=y++ + y++ + y++ + y++;
    printf(" z = %d",z);
    }
    in the above code, the output is 4
    but when the statement z=y++ + y++ + y++ + y++; is changed to z=y++ + ++y + ++y + y++; the output changes to 12. Can somebody explain how the two statements works?
    Thanks


    Posted by: Shatish Kumar Pandey on 3/13/2011

    Contact Shatish Kumar Pandey Contact Shatish Kumar Pandey
    Category Computers Interview Questions
    Rating (0.2) By 219 users
    Added on 3/13/2011
    Views 383
    Rate it!
    Answers:

    In programing instruction, suppose, y=1 if z=y than value of z is 1 (because first it assign value of y to z and than increment in y by 1) and if z= y than value of z is 2 (because it increment in y by 1 and than assign that value to z) so that, in our case,
    z = y y y y
    Z = 1 3 4 4 at finally,
    Z = 12.



    Posted by: Sagar udhwani    

    Contact Sagar udhwani Contact Sagar udhwani

    z=y++ + ++y + ++y + y++
    = 1 + 3 + 4 + 4
    =12.
    How the above values are calculated is explained below:
    The above expression hold y in 4 places.
    In first,it hold 1 and the value 1 is used in expression then incremented because it is postfix y++.
    Now y=2.
    In second term,y is incremented before it is used because it is ++y.so here y=2+1=3.
    In third term, y is also incremented before it is used because it is y++.so here y=3+1=4.
    In fourth term,y is used then only it is incremented because it is y++.so the value 4 is used here.
    After that the present y hold the value 4+1=5.



    Posted by: sophiya    

    Contact sophiya Contact sophiya

    12



    Posted by: ganavi reddy    

    Contact ganavi reddy Contact ganavi reddy

    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
    How To Get Back The Deleted folders in Windows XP ?
    View Answer
    if physical addresse and mac addresse is same then why in my system mac addresse and physical address is different ????
    View Answer
    What is the main function of scanf in C++?
    View Answer
    Difference bettween FAT and NTFS Partition?
    View Answer
    Difference between lcd and tft moniter?
    View Answer
    what is computer
    View Answer
    Differentiate Between Static RAM and Dynamic RAM in Tabular form.
    View Answer
    difference between run time and static memory allocation with an example
    View Answer
    what is the booting process in operating systems
    View Answer
    Compare having one ALU that is twice as fast as normal to having two ALUs
    View Answer
    IN VB 6.0 HOW TO CREATE A REPORT
    GIVE ANSWER STEP BY STEP
    View Answer
    write a C program to create a tabular column
    View Answer
    What is the difference between the *system tray* and the *quick launch tray*?
    View Answer
    Why does defragment (defrag) go only so far and then stop and start over again? I get the message "Drive's Contents Have Changed: Restarting..." How can I get it to finish?
    View Answer
    What steps should I take to replace the bios battery.
    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 Computers 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