retagged by
1,157 views
2 votes
2 votes

what is the o/p
 

#include<stdio.h>
void main()
    {
    int a=5;
    printf("%d   %d   %d",a++,++a,--a);
    }


also suggest me notes so i can clear my concept about printf function (For Gate)

retagged by

6 Answers

Best answer
1 votes
1 votes

According to C standard, the answer is undefined as "Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored."   

To know more read this explanation : https://www.quora.com/What-does-an-expression-involving-multiple-post-pre-decrement-increment-operators-evaluate-to-in-C-and-C++

selected by
0 votes
0 votes
The result is dependent on the compiler as wether the expression should be evaluated from left-to-right or right-to- left is not defined anywhere . Different compiler use to evaluate the given expression in different way.

 

This is an ambiguous question and will not be asked in GATE for sure.

Related questions

3 votes
3 votes
1 answer
1
5 votes
5 votes
3 answers
2
suvasish pal asked Aug 26, 2017
627 views
Will it result in to an error if a header file is included twice?[A].Yes[B].No[C].It is compiler dependent
1 votes
1 votes
1 answer
3
Vasu Srivastava asked Aug 18, 2017
1,051 views
#include <stdio.h int main(void){ int i=511; char *p = (char *)&i; printf("%d", *p); }OK so why take 2's complement and not simple binary number? Means, why is C giving -...
2 votes
2 votes
1 answer
4
Sugumaran asked Feb 7, 2018
494 views
#include<stdio.h int main() { int x=191; char *p; p=(char*)&x; printf("%d",*p); }explain it