void main()
{
int i=5;
printf("%d",i++ + ++i);
}

Answers were Sorted based on User's Feedback



void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / basha

I have compiled this program. The ans is 12

Is This Answer Correct ?    45 Yes 6 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / dhakchina moorthy.p

12

Is This Answer Correct ?    27 Yes 5 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / ravinder

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 ?    24 Yes 8 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / alan

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 ?    16 Yes 8 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / vignesh1988i

the answer is 12..... 5 + 7

Is This Answer Correct ?    12 Yes 8 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / abhijeet dongre

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 ?    8 Yes 5 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / nikki

its 12..
from right to left since printf executes from right to left for processing

Is This Answer Correct ?    3 Yes 0 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / vivers

There are two different questions..
in which its asking the result for

1)(i++ + ++i)
answer will be---> 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"

2) (i+++++i)
answer will be---> compile error
"because illegal combination of operators"


best of luck...

Is This Answer Correct ?    2 Yes 0 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / koushik ramesh

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 ?    6 Yes 5 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / hussain reddy

12

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

What's the best way to declare and define global variables?

7 Answers  


Why is c called "mother" language?

0 Answers  


Can you please explain the difference between strcpy() and memcpy() function?

0 Answers  


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

0 Answers  


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

0 Answers  






Study the Following Points: a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static 1. Which of the Following Statements are true w.r.t Bit- Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture,


wat are the two methods for swapping two numbers without using temp variable??

2 Answers  


What is operator precedence?

0 Answers  


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

0 Answers   Mind Tree,


What is malloc and calloc?

0 Answers  


Write a program to display the no of bit difference between any 2 given numbers eg: Num1 will 12->1100 Num2 will 7->0111 the difference in bits are 2.

4 Answers  


What are the header files used in c language?

0 Answers  


Categories