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=1;
printf("%d%d%d",i,++i,i++);
}
Cau u say the output....?

Answers were Sorted based on User's Feedback



void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / saurabh mehra

3 3 1

Is This Answer Correct ?    146 Yes 51 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / arnob kumar pal

Yes, but before giving the answer I wanna discuss the question.
In printf() function compiler calculates the values from
right to left (i.e. at first calculates the vale of i++,
then ++i and at last i)but prints the values from left to right.
So compiler at first calculates the value of i++, here i=1
so the value is printed 1 for i++, in the post increment the
value of i becomes 2, but in the pre increment which is ++i,
the value becomes 3, so the value is printed 3 for ++i, now
the value of i is 3, for this reason the value is printed
again 3 for i. But as I said before printf() function prints
from left to right
so the output will be 3 3 1

Is This Answer Correct ?    91 Yes 16 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / vignesh1988i

sorry for not explaining it.

this is due to a concept of STACK which is a DATA STRUCTURE.

take the statement : printf("%d%d%d",i,++i,i++);

this list of variables will be getting stored in the stack. like the way shown:
i++
++i
i
since the operation of the stack is LIFO(last in first out)
the process will be done as said as LIFO but while retriving the data it will be printing according to the printf statement so only the output 3 3 1

Is This Answer Correct ?    49 Yes 14 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / vignesh1988i

the output will be 3 3 1.

Is This Answer Correct ?    23 Yes 8 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / ravi

331

Is This Answer Correct ?    16 Yes 6 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / tommy tom

331

Since printf can't know how many operands will be passed in, and since it was made during a time of limited computing resources, the operands are pushed onto a stack, and evaluated after being popped off, thus they are evaluated in LIFO order, or right to left.

i++ is printed as 1, then incremented.
++i is incremented then printed as 3
i = 3.

Reassembling in the order as passed into the function then, 331

There are no spaces or line returns in the format string either, so after the run, the terminal prompt will be tacked directly onto the end of the program's output.

Is This Answer Correct ?    10 Yes 4 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / bala

ans is 3 3 1 and am damn sure

Is This Answer Correct ?    5 Yes 2 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / manikanta

3,3,1

Is This Answer Correct ?    3 Yes 1 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / govind bhone

3 3 1

Is This Answer Correct ?    3 Yes 1 No

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?..

Answer / adad

printf ("a++=%d ++a=%d
", a++,++a);
printf ("++b=%d b++=%d
", ++b,b++);

What about this?

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C C++ Errors Interview Questions

Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }

25 Answers   HCL,


To generate the series 1+3+5+7+... using C program

18 Answers  


UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

5 Answers  


errors are known as?

3 Answers   EX, State Bank Of India SBI,


Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

3 Answers  


what are the techniques for reducing the fragility of a memory bug?

1 Answers  


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


wap for bubble sort

3 Answers  


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

14 Answers   HCL,


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


Categories