You are on page 1of 8

IDEAL INSTITUTE OF ENGINEERING

NAME: - AMIT BIKRAM MISHRA


YEAR: - 1st SEMESTER: - 2nd
SUBJECT: - PROGRAMMING FOR PROBLEM
SOLVING (ESCS - 201)
STREAM: - COMPUTER SCIENCE
AND ENGINEERING
TOPIC: - ARITHMETIC EXPRESSIONS AND
PRECEDENCE
ROLL NO.: - 27900122002
REG. NO.: - 222790110002
CONTENTS
Sl. TITLE PAGE
No. NO.
1 ABSTRACT 1
2 INTRODUCTION 2
3 ARITHMETIC EXPRESSIONS 3
4 PRECEDENCE 4
5 CONCLUSION 5
6 REFERENCE 6
ABSTRACT
In this report, we will be discussing about ‘Arithmetic
expressions and precedence’. Arithmetic expressions are a
combination of operands interjoined with arithmetic operators.
They ultimately evaluate to a single value. We, humans, use a
technique called BODMAS to evaluate arithmetic expressions in
our real life, but the computers and the C programming
language make use of a similar but different technique. They
use precedence and associativity.
INTRODUCITON
An arithmetic expression is a combination of variables,
constants, and arithmetic operators. Arithmetic operators
supported in C are +,-,*, / and%. The operands include integer
and floating-type numbers. Some algebraic expressions and
their corresponding C expressions are given in the following
table:
Algebraic expression C expression
(a+b)(a-b) (a+b)*(a-b)
ab/c (a*b)/c

2x2+3x 2*x*x + 3*x

Arithmetic expressions are evaluated using an assignment


statement of the form
variable = expression
. The expression is evaluated first and the value is assigned to
the variable. An example of an evaluation statement is,
c=a-b/d+e

To determine the meaning and value of an expression in an


unambiguous manner, we apply the operator precedence and
associativity rules.
ARITHMETIC EXPRESSIONS
An Arithmetic Expression is a combination of operands and
Arithmetic operators, such as addition, subtraction, and so on.
These combinations of operands and operators should be
mathematically meaningful, otherwise, they cannot be
considered as an Arithmetic expression in C.
There are four types of expressions exist in C:
o Arithmetic expressions

o Relational expressions

o Logical expressions

o Conditional expressions

Each type of expression takes certain types of operands and


uses a specific set of operators. Evaluation of a particular
expression produces a specific value.

For example:
x = 9/2 + a-b;

The entire above line is a statement, not an expression. The


portion after the equal is an expression.
The Arithmetic expressions are evaluated by performing one
operation at a time. The precedence and associativity of
operators decide the order of the evaluation of individual
operations.
PRECEDENCE
To determine the meaning and value of an expression in an
unambiguous manner, we apply the operator precedence and
associativity rules. The precedence of operators in C dictates the order
in which the operators will be evolved in an expression. Associativity,
on the other hand, defines the order in which the operators of the
same precedence will be evaluated in an expression. Also, associativity
can occur from either right to left or left to right. Operator precedence
helps us determine which of the operators in an expression must be
evaluated first in case the expression consists of more than a single
operator.
CONCLUSION
Arithmetic operators are responsible for performing most
calculations that use values such as: Although labeled
arithmetic operators, these operators are used in algebra and a
number of other mathematical concepts, but retain the same
function wherever they are used.
The precedence of an operator specifies how "tightly" it binds
two expressions together. For example, in the expression 1 + 5
* 3, the answer is 16 and not 18 because the multiplication
("*") operator has a higher precedence than the addition ("+")
operator. Parentheses may be used to force precedence, if
necessary.
REFERENCES
 https://www.javatpoint.com/c-expressions
 https://www.techopedia.com/definition/25582/arithmetic-operator
 https://teachics.org/c-programming-tutorial/arithmetic-expressions-and-
operator-precedence-in-c/

You might also like