Arithmetic operators in action : Arithmetic Operators « Operator « C Tutorial






  1. Arithmetic operators: +, -, *, \ and the modulus operator %.
  2. % cannot be used for float data type or double data type.
#include<stdio.h>

main(){
  int a = 1,b = 2,c = 3,d = 4;
  int sum,sub,mul,rem;
  float div;
  sum = b+c;
  sub = b-c;
  mul = b*c;
  div = b/c;
  rem = b%d;
  a = b/c * d;
  printf("\n sum = %d, sub = %d, mul = %d, div = %f",sum,sub,mul,div);
  printf("\n remainder of division of b & d is %d",rem);
  printf("\n a = %d",a);
}








5.2.Arithmetic Operators
5.2.1.Common Arithmetic Operators
5.2.2.Arithmetic operators in action
5.2.3.Using the Addition operator