Previous: 5.6 Summary
Up: 5 Numeric Data Types and Expression Evaluation
Next: 5.8 Problems
Previous Page: 5.6 Summary
Next Page: 5.8 Problems
if (z = x) printf("z = %d, x = %d\n", z, x);
int a = 10, b = 15, c = 25; float x = 15; double y = 30; long int m = 25L;What are the values and types of the following expressions:
a + b / c * x; a + b / x * c; a + b / y * c; a + b / m * c;x + a / b; x + (int) a / b;
int x, y, z; float u, v, w;x = 10; y= 20; z = 30;
x = z / y + y; x = x / y / z; x = x % y % z
int x, y, z; float u, v, w; x = 10; y= 20; z = 30; u = 5.0; v = 10.0; w = 30.0;x = w / y + y; u = z / y + y; u = w / y + y; u = x / y / w + u / v;
#define PRHAPS #define TWICEZ z + zmain() { int w, x, y, z; float a, b, c; w = 16; x = 5; y = 15; z = 8; a = 1.0; b = 2.0; c = 4.0;
#ifdef PRHAPS x = 15; y = 5; #endif
printf("(a). %d %d\n", x, y); printf("(b). %d\n", TWICEZ * 2); printf("(c). %f %f\n", w / z * a + c, z / w * b + c); printf("(d). %d\n", z % y % x); }
#define SWAP(x, y) int temp; temp = x; x = y; y = temp main() { int x1 = 10, x2 = 20;SWAP(x1, x2); printf("x1 = %d, x2 = %d\n", x1, x2); }
#define SWAP(x, y) {int temp; temp = x; x = y; y = temp;} main() { int x1 = 10, x2 = 20;SWAP(x1, x2); printf("x1 = %d, x2 = %d\n", x1, x2); }
#define SWAP(x, y) int temp; temp = x; x = y; y = temp main() { int x1 = 10, x2 = 20;printf("Swapping Values\n"); SWAP(x1, x2); printf("x1 = %d, x2 = %d\n", x1, x2); }
int x = 100, y;What are the values of x and y after each of the following expressions is evaluated (the expressions are evaluated in sequence)?
y = x++; y = ++x; y = --x; y = x--;
x = 100; y = 200; y = y++ - ++x; y = ++y - x++; y = ++y * 2; y = 2 * x++;
x = 100; y = 200; y += 2 * x++; y -= 2 * --x; y += x;
x = 100; y = 200; z = 25; z = y > x ? x : y; z = (z >= x && z >= y) ? z - x * y : z + x * y;