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 / vinay,

:) its just how the Compiler parses things..

the..maximum matching (of a token) principle... from the
left..

1. i++ is a valid maximum match. Good, next
2. + match, next (expects a + or a identifier,for furthur
match)
3. + (this is not a identifier, but a + will do so:
match=++). Next the parser wants an indentifier.. else
compiler flags an error..
4. + (not an identifier.. so.. fails)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / ashwini

This gives an error. The error is as below:
error C2105: '++' needs l-value

if we correct the code to printf("%d", i++ + ++i);

We get the answer as 12...

The above printf becomes a statement when it sees the
semicolon. Unary operators have right to left associativity.
So, ++i is evaluated first to 6. Then, i++ is evaluated. i++
contributes 6 to addition and then increments i. So, we get
the answer as 12.

Is This Answer Correct ?    1 Yes 1 No

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

Answer / shivam shukla

all of you are breaking the statement i+++++i correctly as
i++ + ++i and your answer 12 is also write but you are
explaining it the wrong way......first i++ will make the
value 6 and again a ++i will make it 7 but inn actual
calculation of i++ + ++i....5+7.....will be calculated
hence we get the value 12

Is This Answer Correct ?    0 Yes 0 No

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

Answer / ashvin solanki (srimca college

There will be a compilation error .....

Is This Answer Correct ?    0 Yes 0 No

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

Answer / shruti

i think it will give a compilation error..

Is This Answer Correct ?    1 Yes 2 No

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

Answer / sulochana

This statement is just i=i++ + ++i;
Initially i=5
i++ increments after the statement completed For now its
value is 5.
++i increments before its execution.so it is 6
It executes like
i=5+6; i.e. i=11

Is This Answer Correct ?    2 Yes 8 No

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

Answer / guest

the condition is like i++ + ++i

so 5 + 6 =11

Is This Answer Correct ?    10 Yes 25 No

Post New Answer

More C Interview Questions

Explain enumerated types in c language?

0 Answers  


Which of these functions is safer to use : fgets(), gets()? Why?

0 Answers  


Write a program that his output 1 12 123

0 Answers  


What is malloc return c?

0 Answers  


How can I use a preprocessorif expression to ?

0 Answers  






What is the 'named constructor idiom'?

0 Answers  


what are the facialities provided by you after the selection of the student.

0 Answers   TCS,


How can I change the size of the dynamically allocated array?

0 Answers  


Is a house a mass structure?

0 Answers  


write a prgram of swapping with 2 valiables

6 Answers  


write a program to generate 1st n fibonacci prime number

2 Answers  


What is an example of structure?

0 Answers  


Categories