C Programming and Data Structures May/June 2008 SET- 2 1.
(a) (b) (c) (d)
Explain the working of unary operator with example. Explain the working of binary operator with example. Explain the working of assignment operator with example. Explain the working of ternary operator with example.
Ans: (a) C supports a rich set of operators, such as +,-,=,*,& and <. 1. An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations. 2. Operators are used in programs to manipulate data and variables. They usually form a part of the mathematical or logical expressions. 3. C operators can be classified into a number of categories. They include: 1. arithmetic operators. 2. relational operators. 3. logical operators 4. assignment operators 5. increment or decrement operators. 6. conditional operators 7. bitwise operators 8. special operators. C provides all the basic arithmetic operators. These operators are +, -, * and /. All work the same way as they do in other languages. They can operate on any built-in data type allowed in c. Unary Operators
Unary operators include 1. addition or unary plus 2. subtraction or unary minus 3. increment operator (++) 4. decrement operator (--) 5. address operator 6. size operator The following table summarizes these operators.