homecode zoneQuick Codedownloadssubmit codeabout usfeedbackscontact ussitemap
 
Beginners
Intermediate
Proffessional
Array
Array & String
Looping
Branching
Constant Variable & Data type
Operators
Function
Structures & Unions
Pointers
Liabrary
Pro - Languages
C/C++
Java
Visual basic
asp
vb.net 2003/2005
asp.net
Quick Code
SUBMIT CODE
Mail List
LINKS
Submit LINK
 
ProgrammerGuide.net -Operators.
Home » C/C++ Zone » Operators

Introduction

C supports a rich set of operator .We have already used several of them ,such as =, +, -, /, *, & and <, an operator is a symbol that tells the computer to perform certain mathematical or logical manipulation. Operator are used in programs to manipulate data and variable

C operator can be classified into a number of categories They include.
 

1. Arithmetic operator 5. Relational operator
2. Logical operator 6. Assignment operator
3. Increment and Decrement operator 7. Conditional operator
4. Bitwise operator 8. Special operator

Arithmetic Operator

C provides all basic arithmetic operator. They are listed in Table 3.1. The operator are +, -, *, and / all work the same way as they do in other language. These can operate on any built in data type allowed in C. The unary minus operator, in effect, multiplies its single operand by -1 therefore number preceded by a minus sign changes its sign.
 
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Percentage

Integer division truncates any factorial part .The modulo division operators procedure The reminder of an integer division. Examples of use of arithmetic operators are:

a - b     a + b
a * b     a / b
a % b     -a * b

Here a and b are variable and are known as operands .The modulo division operator % cannot be on floating point data. Older version of c does not supports unary plus but ANSI C supports.

Integer Arithmetic

When both the operands are in a single arithmetic expression such as a + b are integers, the expression is called  an integer expression, and operation are called integer arithmetic .Integer arithmetic always  yields an integer value.
 
a - b = 10
a + b = 18
a * b = 56
a / b = 3
a % b = 2

Similarly ,during modulo division, the sign of the the result is the always sign of the first operand that is
 
-14 % 3 = -2
-14 % -3 = -2
14 % -3 = 2

Real Arithmetic

An arithmetic operation is involving is only real operand is called real arithmetic. Arial operand may assume value either in decimal or exponential notation. Since floating point values are reduced to the number of significant digit permission
 
x = 6.0 / 7.0 = 0.857143
y = 1.0/3.0 = 0.333333
z = -2.0 /3.0 = -0.666667

The operator % cannot be used with real operands. Mixed-mode arithmetic When operands are real and other is integer, the expression called Mixed-mode arithmetic expression, if either operands is of the real types, then only the real operation if performed and the result is always a real numbers.





« Previous 1 2 3 4 5 Next »

Viewers: 13
Visitors:127291
Last Updated on:Sunday, January 17, 2010
Home | About us | Feedback | Contact us | Sitemap
Copyright © 2008 ProgrammerGuide.net. All rights reserved.
This site is best viewed in IE 6.0, Firefox 1.5 and above with screen resolution of 1024 X 768.