Sponsered Links
Categories
Sponsered Links

C language Arithmetic operators

 

This is a C language Arithmetic operators

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

See the table below:

Operator Description Example
* Multiplication Result = Operand1 * Operand2;
/ Division Result = Operand1 / Operand2;
% Modulus (remainder) Remainder = Operand1 % Operand2;
+ Addition Result = Operand1 + Operand2;
- Subtraction Result = Operand1 -Operand2;

#include<stdio.h>

main(){
  int a = 2, b = 3, c = 4, d = 5;
  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);
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved