You are on page 1of 6

ABDU GUSAU POLYTECHNIC TALATA MAFARA

ZAMFARA STATE
DEPARTMENT OF COMPUTER SCIENCE
NDI COMPUTER SCIENCE
GROUP ASSIGNMENT

COURSE
C PROGRAMMING
BY
GROUP 5
S/NO NAMES REG NO
1. AFENI IYABO OLUWAKEMI 2107031053
2. OBAYORI DEBORAH 2107031013
3. ABDULLAHI IBRAHIM 2107031094
4. AISHA AMINU 2107031140
5. AMIRU SHEHU 2107031146

QUESTION
Write on arithmetic operation and differentiate between unary
arithmetic operation and binary arithmetic operation

TO BE SUBMITTED TO MAL: BELLO MADA

1
INTRODUCTION
An arithmetic operator in programming is a subset of these indicators or symbols that
denote that a specific mathematical operation is needed. You can think of them much
like their real-world equivalents. They form part of a program statement that determines
the result required. For example, you would use one or more operators to calculate the
total dollars you are paid in your paycheck or the total amount you owe when you
purchase an item. Operators impact many aspects of our lives, although we are often
unaware of them. They do their thing quietly, behind the scenes, as part of the
computers we employ.
WHAT IS ARITHMETIC OPERATOR?
An arithmetic operator is a mathematical function that takes two operands and performs
a calculation on them. They are used in common arithmetic and most computer
languages contain a set of such operators that can be used within equations to perform
a number of types of sequential calculation. Basic arithmetic operators include:

 Addition (+)
 Subtraction (-)
 Multiplication (×)
 Division (÷)
Computers use different symbols in programming to represent multiplication (*) and
division (/). More complex operators such as square root (√) also act as arithmetic
operators but the basic plus, minus, multiply and divide are the fundamental operators.
Arithmetic operators have been used in mathematics formulas and numeric calculations
for centuries. They form the basis for determining the outcome of calculated numbers or
products. Their use is linear; each operator is performed in sequence, with multiplication
and division taking place before addition and subtraction.
Arithmetic symbols such as the % have different meanings when used in computing and
are dependent on the language in question. 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.

2
3
DIFFERENCE BETWEEN UNARY AND BINARY ARITHMETIC OPERATOR
Unary Binary Ternary
(i) The operators which act (i) The operators which ternary operator allows executing
upon a single operand are require two operands different code depending on the value of
called unary operators. for their action are a condition. The returned value is the
called binary result of the expression when the code
operators. is executed.
(ii) They are pre-increment (ii) They are Ternary operator can be used in place
and post increment (+ +). mathematical of if-else statements. Ternary operator
operators and is also known as conditional operator,
relational operators. which I guess is more meaningful, as it
evaluates the conditions just like if.

UNARY ARITHMETIC OPERATORS


Unary operators are arithmetic operators that perform an action on a single operand.
The script language recognizes the unary operator negative (-). The negative unary
operator reverses the sign of an expression from positive to negative or vice-versa. The
net effect is that of multiplying the number by -1. Example:

Examples
a = -10;
x++ (operand is x)
BINARY ARITHMETIC OPERATORS
Insert a space before and after an arithmetic operator. The binary arithmetic operators
that are supported are listed below.

Example
Ex: y * 7 (operands are y and 7).

TERNARY OPERATOR
Ternary operator in C language. It takes three operands and is used to evaluate one of
the two alternative expressions depending on the outcome of a test expression. The
controlling condition of the ternary operator must evaluate to boolean, either true or
false .

Examples

4
(age >= 18) ? printf("Can Vote") : printf("Cannot Vote");

5
REFERENCE
Chrisomalis, Stephen (2010), Numerical Notation: A Comparative History, Cambridge University Press,
pp. 42–43, ISBN 9780521878180.
Edward Hacker; Steve Moore; Lorraine Patsco (2002). I Ching: An Annotated Bibliography. Routledge.
p. 13. ISBN 978-0-415-93969-0.
Redmond, Geoffrey; Hon, Tze-Ki (2014). Teaching the I Ching. Oxford University Press. p. 227. ISBN 978-
0-19-976681-9.
Robson, Eleanor; Stedall, Jacqueline, eds. (2009), "Myth No. 2: the Horus eye fractions", The Oxford
Handbook of the History of Mathematics, Oxford University Press, p. 790, ISBN 9780199213122
Rudman, Peter Strom (2007), How Mathematics Happened: The First 50,000 Years, Prometheus Books,
pp. 135–136, ISBN 9781615921768.

You might also like