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 ?    145 Yes 50 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 ?    90 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 ?    48 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

How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis

0 Answers  


when i use cout or cin call & then either << or >> .....it shows declaration syntax error...what should i do? cout<<"anything"; int a; cin>>a; return 0;

2 Answers  


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

1 Answers  


Answering Yes or No in C++...using only stdio.h and conio.h..........help me please...? here's must be the output of the program: Screen A Exam No. items Score 1 20 20 2 35 35 Another Entry? [Y] or [N] : Screen B: Record No. Student's Name: 1 Fernando Torres 2 Chuck Norris Note: if you press Y, the program must repeat the procedure in screen A, then if N, the program must proceed to the screen B....Please Help me out............

1 Answers  


Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  






printy(a=3,a=2)

3 Answers  


Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly

1 Answers   AMA,


2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]

0 Answers  


Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


main() { char c; for(c='A';c<='Z';c++) getch(); }

9 Answers  


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


wap for bubble sort

3 Answers  


Categories