next up previous contents
Next: 關係運算子 Up: 運算子 Previous: 運算子   Contents

算術運算子

  1. +
    int A=10, B=20, C;
    C=A+B;
    printf("C=%d\n",C);
    
  2. -
    int A=10, B=20, C;
    C=A-B;
    printf("C=%d\n",C);
    
  3. *
    int A=10, B=20, C;
    C=A*B;
    printf("C=%d\n",C);
    
  4. /
    int A=10, B=20, C;
    C=B/A;
    printf("C=%d\n",C);
    
  5. %
    int A=10, B=21, C;
    C=B%A;
    printf("C=%d\n",C);
    
  6. ++
    int A=10, B=20, C;
    C=A++;
    printf("C=%d\n",C);
    
  7. --
    int A=10, B=20, C;
    C=A--;
    printf("C=%d\n",C);
    



2015-01-16