#include<stdio.h>
void main()
{
int i=1;
printf("%d%d%d",i++,++i,i);
}
Answers were Sorted based on User's Feedback
Answer / medo
221...
In printf() function compiler calculates the values from
right to left,but prints the values from left to right.
| Is This Answer Correct ? | 28 Yes | 13 No |
Answer / samrat
The Ans is: 2,3,3
In printf() the evaluation starts from right and the
printing of the values start from left.
Coming from right, the initial value is 1, after that ++i
will increment the value of i to 2. Now i++ will not be
incremented now. It will be incremented after the first "i"
is printed.
So we print 2 first, then the value of i is incremented to 3
(by executing i++). So for the other two i's the value will
be 3. So the ans is 2,3,3
| Is This Answer Correct ? | 13 Yes | 6 No |
Basically in printf the values are calcualted from right to left...and the output is displayed from left to right.
so the output will be
221
first one will be printed
then one will be incremented by one and made as two..since it is a pre increment and will be printed..
then the value now is 2..so it will be printed then it will be incremented { post increment }..
good question..
a typical example for working of Printf
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / prem_mallappa
The right answer is : Unpredictable/implementation defined behaviour.
Why? : get a C faq's book or visit online at c-faq.org
Reason: variable 'i' is changed more thane once between 'sequence point', a sequence point is a semicolon in 'C'. in such cases the result is unknown or compiler dependent.
| Is This Answer Correct ? | 1 Yes | 0 No |
I AM RICKY DOBRIYAL
THIS ANSWER IS DEFINETLY CORRECT
221
BECAUSE COMPILER CALCULATE RIGHT TO LEFT
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / mementomori76
answer is 221, but you shouldn't use void main
it's better to use int main()
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rakesh
121
the first value is post increment(++i) and so at the first compilation the value is not incremented.. the next value is pre increment(i++) so it is incremented at the first compile. the third is the same as the input.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shahenshah07
its o/p:2 2 1
cause when parameter pass to any f'n its stored in a
stack(lifo).dats y its print i,++i;i++ respectively.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the different types of errors in C and when they occur?
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.)
how tally is useful?
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
How to reverse a linked list without using array & -1? Thank you.
To generate the series 1+3+5+7+... using C program
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]
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?
which typw of errors ? & how to solve it ?
difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }
what is the large sustained error signal that eventually cause the controller output to drive to its limit