Monday, May 10, 2010

Signed and Unsigned

1. What is the output of the following program
main() {
unsigned int a = 10;
int b = -19;
puts((a+b)>0? "Positive":"Negative");

Answer : Positive
Explanation : When signed and unsigned arithmetic is done, signed is converted to unsigned and result will be unsigned, ANSI C standard.

No comments:

Post a Comment