CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

Sponsored Links

Interview Questions
Our Services



INTERVIEW QUESTIONS PROGRAMMING 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/2013

Contact manish Contact manish

Category Programming Languages Interview Questions
Rating (3.6) By 47 users
Added on 7/9/2013
Views 658
Rate it!


Answers:

Source: CoolInterview.com

x=1702 y=2560
Source: CoolInterview.com



Posted by: logesh

Contact logesh Contact logesh

Source: CoolInterview.com

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
Source: CoolInterview.com



Posted by: sarathy C.R

Contact sarathy C.R Contact sarathy C.R

Source: CoolInterview.com


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 .
Source: CoolInterview.com



Posted by: krishna

Contact krishna Contact krishna

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 Programming Languages Interview Questions & Answers



User Options
India News Network

Latest 20 Questions
What is an execution plan? When would you use it?
What is BCP? When does it used?
What are the advantages of using Stored Procedures?
What is a Scheduled Jobs or What is a Scheduled Tasks?
What is NOT NULL Constraint?
What is CHECK Constraint?
What is FOREIGN KEY?
What is UNIQUE KEY constraint?
What is PRIMARY KEY?
What is the difference between a Local and a Global temporary table?
Name 3 ways to get an accurate count of the number of records in a table?
What is Log Shipping?
What is SQL Server Agent?
Which command using Query Analyzer will give you the version of SQL server and operating system?
What are the authentication modes in SQL Server? How can it be changed?
What is SQL Profiler?
What are the properties and different Types of Sub-Queries?
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
When is the use of UPDATE_STATISTICS command?
What is difference between DELETE and TRUNCATE commands?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

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

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




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



Cache = 0.015625 Seconds