Sunday, June 22

What are ARITHMETIC OPERATORS used in c++


Hello friends, hope you have liked my blog , today our topic is, what are arithmetic operators ?.Arithmetic operators are the basic and common operations performed using any computer programming. Normally these operators are considered as basic operators and known as a binary operators as they required two variables to be evaluated. For example if we want to add any two numbers then we will have to feed addend and augend i.e why it is sometimes called binary operator. In C++ the arithmetic operators are as follows :
OPERATOR>>> MEANING
+ >>> addition
- >>> subtraction
* >>> multiplication
/ >>>division
% >>> modulo(remainder of an integer division)

The operator /(slash) for division deserves a special attention. If we divide an integer by another integer, we obtain an integer value.... 39/5 = 7.
If any one of the operands a or b is a float in a/b then the result will be in float. This also happens to other operators as well..... For example>>
4+3=7 (integer type)
4.0+3.0=7.0 (floating point)
as:
39/7= 5
39/7.0= 5.57
39.0/7= 5.57
39.0/7.0= 5.57
The result obtained by division is called quotient. Remainder can be obtained by a another operator %... For example,
39%5 gives 4

EXPRESSIONS: An expression is a collection of data object and operands that can be evaluated to single value. An object is a constant, variable or any other expression.
The most general form is,
object1 expression object2
The results is a new data object. For example >>
2+3 evaluates 5
3-7 evaluates -4
To avoid errors generally grouping is done by using parentheses '()' , it makes program readable and logical. Following precedence is used to calculate the results by the C++ compilers
() >> for grouping variables
- >> unary for negative number
*, / >> multiplication and division
+,- >> addition and subtraction
So if you want to calculate as how compiler calculates use the above precedence...
Thanks for reading my this post , come tomorrow for some new post........

0 comments:

Followers

Archive

 

Money ,Entertainment and Education. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com