GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  could any one explan me what happens in this program.

main(){
int i=10;
i=(++i)/(i++);
printf("i=%d",i);
}




February 02, 2008 01:13:14 #10
 chethan HB Testing Expert  Member Since: November 2005    Total Comments: 2 

RE: could any one explan me what happens in this program. main(){ int i=10; i=(++i)/(i++); printf("i=%d",i); }
 
1. i ++ will get execute so the value will be 10 . it wont increment.
2. ++i will be incremented to 11
3. 11/10 will result to 1
4.i=1 will get execute.
5. keep in mind still increment is not done.. this is done after exectuing , or ;
6. after executing i=1  ';' will be executed
7. i++ will get incremented to 2

so the answer is 2.
     

 

Back To Question