10

Les opérateurs

  1. #include <stdio.h>
  2.  
  3. main() {
  4.     int a = 38, b = 5;
  5.     int c = -b;
  6.  
  7.     printf("\t-a = -(%d) = %d\n", a, -a);
  8.     printf("\ta + b = %d + %d = %d\n", a, b, a + b);
  9.     printf("\ta - b = %d - %d = %d\n", a, b, a - b);
  10.     printf("\ta * b = %d * %d = %d\n", a, b, a * b);
  11.     printf("\ta / b = %d / %d = %d\n", a, b, a / b);
  12.     printf("\ta %% b = %d %% %d = %d\n", a, b, a % b);
  13.     printf("\n");
  14.     printf("\t-c = -(%d) = %d\n", c, -c);
  15.     printf("\ta + c = %d + %d = %d\n", a, c, a + c);
  16.     printf("\ta - c = %d - %d = %d\n", a, c, a - c);
  17.     printf("\ta * c = %d * %d = %d\n", a, c, a * c);
  18.     printf("\ta / c = %d / %d = %d\n", a, c, a / c);
  19.     printf("\ta %% c = %d %% %d = %d\n", a, c, a % c);
  20. }
$ 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

Votre commentaire :
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip aide 2000

Entrez un maximum de 2000 caractères.
Améliorez la présentation de votre texte avec les balises de formatage suivantes :
[p]paragraphe[/p], [b]gras[/b], [i]italique[/i], [u]souligné[/u], [s]barré[/s], [quote]citation[/quote], [pre]tel quel[/pre], [br]à la ligne,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]commande[/code], [code=langage]code source en c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].