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
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 |
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 |
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 |
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 |
I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00
which typw of errors ? & how to solve it ?
I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.
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............
Write a c-programe that input one number of four digits and find digits sum?
Why are memory errors hard to debug?
what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?
What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0
main() { char c; for(c='A';c<='Z';c++) getch(); }
How to convert hexadecimal to binary using c language..
1 Answers Bajaj, GAIL, Satyam, Zenqa,
what is exceptions?
#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer