Sha256: 1cb91a65ae5773da7eda23cb1eb74b40a586cb39c2a8d36677334e24a72d99a4

Contents?: true

Size: 424 Bytes

Versions: 10

Compression:

Stored size: 424 Bytes

Contents

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int a, b;
  if (argc < 3) exit(1);
  b = atoi(argv[--argc]);
  if (b == 0) exit(2);
  a = atoi(argv[--argc]);
  printf("a+b = %d\n", a+b);
  printf("a-b = %d\n", a-b);
  printf("a*b = %d\n", a*b);
  printf("a/b = %d\n", a/b); /* truncates towards 0 (in C99) */
  printf("a%%b = %d\n", a%b); /* same sign as first operand (in C99) */
  return 0;
}

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/c.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/c.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/c.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/c.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/c.txt