7

Operators

  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

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[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]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].