10
Les opérateurs
- #include <stdio.h>
- main() {
- int a = 38, b = 5;
- int c = -b;
- printf("\t-a = -(%d) = %d\n", a, -a);
- printf("\ta + b = %d + %d = %d\n", a, b, a + b);
- printf("\ta - b = %d - %d = %d\n", a, b, a - b);
- printf("\ta * b = %d * %d = %d\n", a, b, a * b);
- printf("\ta / b = %d / %d = %d\n", a, b, a / b);
- printf("\ta %% b = %d %% %d = %d\n", a, b, a % b);
- printf("\n");
- printf("\t-c = -(%d) = %d\n", c, -c);
- printf("\ta + c = %d + %d = %d\n", a, c, a + c);
- printf("\ta - c = %d - %d = %d\n", a, c, a - c);
- printf("\ta * c = %d * %d = %d\n", a, c, a * c);
- printf("\ta / c = %d / %d = %d\n", a, c, a / c);
- printf("\ta %% c = %d %% %d = %d\n", a, c, a % c);
- }
$ gcc -o nops nops.c
$ ./nops
-a = -(38) = -38
a + b = 38 + 5 = 43
a - b = 38 - 5 = 33
a * b = 38 * 5 = 190
a / b = 38 / 5 = 7
a % b = 38 % 5 = 3
-c = -(-5) = 5
a + c = 38 + -5 = 33
a - c = 38 - -5 = 43
a * c = 38 * -5 = -190
a / c = 38 / -5 = -7
a % c = 38 % -5 = 3
Commentaires