Raman wrote:
I have small fragment of code ...
Thank you for posting a complete program...
main()
We prefer "int main(void)", but it's only a stylistic thing, really.
{
int n=10;
if(--n==n)
{
printf("\n Pre");
}
if(n--==n)
{
printf(" Post");
}
}//main
Please don't use "//" comments - they're not in the standard that most
of us are working with, and may upset our compilers.
What shall be the output of the above code.
The standard explicitly says this yields undefined behaviour - demons
flying out of your nose or your computer catching fire are unlikely,
but allowed by the standard. It's not guaranteed that this program will
behave consistently on different platforms, or compiled by different
compilers (or with different compiler optimisation).
Empirically this produced "Pre" on my linux workstation, compiled with
some version of GCC. On an AIX server using Xlc (again version
unspecified) I got "Pre Post".
Why do you ask?