Mega Code Archive

 
Categories / C Tutorial / Operator
 

Arithmetic operators in action

Arithmetic operators: +, -, *, \ and the modulus operator %. % 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); }