ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
void main()
{
            int i=5;
            printf("%d",i++ + ++i);
}
 Question Submitted By :: Surenda Pal Singh Chouhan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 1
Output Cannot be predicted  exactly.

Explanation:
Side effects are involved in the evaluation of   i
 
Is This Answer Correct ?    0 Yes 4 No
Surenda Pal Singh Chouhan
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 2
same as the pervious question....

11 ans
 
Is This Answer Correct ?    1 Yes 5 No
Guest
 
 
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 3
I have compiled this program. The ans is 12
 
Is This Answer Correct ?    11 Yes 0 No
Basha
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 4
ans :11
how?
 -> i++ => i=i+1 => i=6;
       
 -> ++i => i=i =>i=5(first assign the value);
           i=i+1;
   
    so i++ + ++i=6 + 5=11 i.e.ans
 
Is This Answer Correct ?    0 Yes 5 No
Sachin
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 5
i++=5
++i=6

so i++ + ++i = 5+6=11
 
Is This Answer Correct ?    0 Yes 5 No
Jignesh Patel
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 6
12
 
Is This Answer Correct ?    6 Yes 0 No
Dhakchina Moorthy.p
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 7
the answer is 12..... 5 + 7
 
Is This Answer Correct ?    1 Yes 1 No
Vignesh1988i
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 8
Ans 12,
as addition will takes place from left to right
step1: i++  = 5;
step2: value of i will be updated before taking value of
another operand and hence i = 6;
step3: ++i = 7 as first increment will happen and then value
will be used.
final result: 5 + 7 = 12;
 
Is This Answer Correct ?    1 Yes 1 No
Ravinder
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 9
when ever a cout or a printf statement is used..the instruction is processed from right to left..

had this been the qn 
int i=5;
printf("%d%d",i++ + ++i,i);

ans would be 125.
as i said earlier the processing takes from right to left..

so first ++i=6,
then i++=6;

therfore 6+6=12..
 
Is This Answer Correct ?    0 Yes 1 No
Alan
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 10
this program output is 12.
 
first is i++ is 5 only because this the post increment
  first using the value after increment.
  
  whenever i++ +  the value of is 6.
 ++ i means this is the pre-increment.first increment
the value after using the variable this step i will become 
7.
total is i++ =5
         i++ + =6
          ++ i=7
    i++ + ++i= 12. this is posted by Ramesh(MCA)Nizam 
college.HYDERABAD
 
Is This Answer Correct ?    0 Yes 1 No
Koushik Ramesh
 
  Re: void main() { int i=5; printf("%d",i++ + ++i); }
Answer
# 11
I HAVE PRACTICED MANY ASPECTS OF THESE QUESTIONS
THING IS THAT 
PRINTING VALUES IS FROM RIGHT TO LEFT.
SOLVING AN EXPRESSION IS FROM LEFT TO RIGHT.
SOME SAMPLE OUTPUTS:-(TRY IT)
int i=5;
printf("%d",i++ + ++i);           12(5+7 only)(not 6+6)

int i=5;
printf("%d",i++ * ++i);           35(5*7 only)(not 6*6)

int i=5;
printf("%d %d",i++ + ++i,i);      12 5

int i=5;
printf("%d",i++ + i++);            11 7
printf(" %d",i);
 
Is This Answer Correct ?    0 Yes 0 No
Abhijeet Dongre
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
how to sort two array of characters and make a new array of characters. Accenture1
we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?  1
wats SIZE_T meant for?  1
Add 2 64 bit numbers on a 32 bit machine NetApp3
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }  2
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?  1
What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); } ADITI5
Program to find the absolute value of given integer using Conditional Operators N-Tech2
What is the memory allocated by the following definition ? int (*x)[10]; ADITI3
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
difference between function & structure Verizon5
when will be evaluated as true/ if(x==x==x) a) x=1; b) x=0; c) x=-1; d) none HCL4
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco5
1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.  2
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance IBM1
What are Storage Classes in C ? HP14
What is the difference between null pointer and the void pointer?  2
disadvantages of realloc ? HCL1
What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value Accenture3
write a function which accept two numbers from main() and interchange them using pointers?  3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com