void main()
{
char a=250;
int expr=a+!a+~a+ ++a;
printf("%d",a);
getch();
}
what is output and plz explain it..:):)
what is output
Unpredictable in all cases.
plz explain it..
The expression a + !a + ~a + ++a
invokes undefined behavior by using the value of a
in a way that doesn't assist in computing the new value. It falls under the sequence point rule of an object being modified at most one time between sequence points and the prior value being accessed only to determine the new value.
Other problems include potentially overflowing a
if char
is signed and CHAR_BIT
is 8, and printing the new value of a
rather than the value of expr
. If the compiler doesn't support it as an extension, void main also invokes undefined behavior.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.