• Call Us: +91 9437911966
  • Email Us: info@studentstutorial.com
  • Home
  • C Examples
  • Server Side
    • PHP
    • Java
    • CodeIgniter
    • Laravel
    • JSP
    • JDBC
  • Frontend
    • HTML
    • CSS
    • Javascript
    • jQuery
    • AJAX
    • FPDF
    • TCPDF
  • APP & DB
    • Android
    • Cordova
    • SQL
    • Oracle
  • Project
C Tutorial C Introduction C Characteristic C Comments C Operator C Assign Operator C Arithmetic Oper.. C Logical Operator C Modulus Operator C Variable C Initialise Variable C Print F C Translators C Programming C Control Flow C If Else Statement C Nested If Else C Loops C While Loops C For Loops C Do While C Nested Loops

C Arithmetic operator

  • Student Tutorial
  • 08 jun 2020
   

When we required evaluating basic mathematical expressions then we required to use asthmatic operators.

Arithmetic operators are of 2 types -

  1. Unary arithmetic operators ++, --
  2. Binary arithmetic operators +, -, *, /, %

Binary Arithmetic Operators

  1. When we are working with these operators we required 2 operands. If any one of the asg. Is missing it gives an error.
  2. In implementation when we are evaluating any expression if that expression contains multiple operators then in order to evaluate that expression we requires to follow priority of the operator.
  3. According to priority which operators are having highest priority it should be evaluate first, which operator contains least priority it should be evaluated at last?
  4. When equal priority is occurred, if it is binary left to right, if it is unary, right to left required evaluating.
    1. *  /  %
    2. +  -
    3. =

A= 2+5; 7 (return values)
A=5+3-4; 4
	8-4
A= 5-4+3; 4
	1+3
A= 2*3+2*3; 12
	6+6
A= 2+3*2+3; 11
2+6+3
A=5+; Error
A= 8-; Error
A= +5;  5
A=-8;  -8


  • When we are working with +, - symbols then it works like a binary and unary operator also.
  • if the symbol is available before the operands then it is unary operators which indicate sign of the value.
  • When the symbol is available after the operands then it is binary arithmetic operators .Which requires 2 arguments.
  • Always expression required to evaluate acc. To operand type only.
  • Always operator behaviour is operand depend only i.e. what type of data we are passing depends only on input type it works.
  • If both arguments are integer then return value is int.
  • Any one of the argument is float or both are float then return value is float type only.
  • Output sign will depends on numerator value sign and determinate value also i.e. if any of the arguments is negative then return value is negative, if both arguments are return value is positive.
  • In division operator when the numerator value is less than of denominator operator then return value is zero if both are integer.

Expression Return Values
5/2 2
5.0/2 2.5
5/2.0 2.5
5.0/2.0 2.5
2/5 0
2.0/5 0.4
-5/2 -2
Student Tutorial is a online tutorial for web design and development. Here you can find easy example and explanation for each tutorial.
Copyright © 2016-2023 Student Tutorial

Server Side

  • PHP
  • Java
  • CodeIgniter
  • Laravel
  • JSP
  • JDBC

Frontend

  • HTML
  • CSS
  • Javascript
  • jQuery
  • AJAX
  • FPDF

App & Database

  • Android
  • Cordova
  • SQL
  • Oracle