#include <stdio.h>char getchar (int x,int y) { char c; unsigned int a = x ; (a + y > 10) ? (c = 1) : (c = 2); return c;} Int main (void) { char c1 = getchar (7,4); char c2 = getchar (7,3); char c3 = getchar (7,-7); char c4 = getchar (7,-8); //c1 = 1 printf ("c1 = %d\n", &NBSP;C1); //c2 = 2 printf ("c2 = %d\n", &NBSP;C2); /*c3 = 2 unsigned types and signed types for operation, * signed types are implicitly converted to unsigned types * - 7 converted unsigned value plus 7 just above overflow, the result is 0 */ printf ("c3 = %d\n", c3); /* c4 = 1 * -8 converted unsigned value plus 7 becomes a very large integer (the difference of 1 will overflow) */ printf ("c4 = %d\n ", c4); return 0;}
This article is from the "Walt" blog, make sure to keep this source http://water3700348.blog.51cto.com/13058625/1965238
Question 1th: The worthwhile conversion of signed and unsigned variables