Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.

5 Answers  


while initialization of array why we use a[][2] why not a[2][]...?

0 Answers   Aptech,


main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }

6 Answers  


main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }

4 Answers   CTS,


enum { SUNDAY, MONDAY, TUESDAY, }day; main() { day =20; printf("%d",); getch(); } what will be the output of the above program

1 Answers  


implement general tree using link list

1 Answers   Wipro,


Write a program to compute the following 1!+2!+...n!

4 Answers  


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

2 Answers   NetApp,


difference between i++* and *++i

6 Answers   IBM,


write a program for the normal snake games find in most of the mobiles.

0 Answers   Accenture, Wipro,


How does placing some code lines between the comment symbol help in debugging the code?

0 Answers  


write a program that print itself even if the source file is deleted?

2 Answers  


Categories