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 is a protocol in c?

0 Answers  


Explain logical errors? Compare with syntax errors.

0 Answers  


What is a program flowchart?

0 Answers  


Which is better between malloc and calloc?

0 Answers  


why the execution starts from main function

9 Answers  






Is stack a keyword in c?

0 Answers  


what are bitwise shift operators?

4 Answers  


What is the description for syntax errors?

0 Answers  


You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;i<n1-1;i++) { if( !( (a1[i]>a1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

0 Answers   Facebook,


Is null valid for pointers to functions?

0 Answers  


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

0 Answers  


What is a program?

0 Answers  


Categories