Friday, September 12, 2008

C Assignments # 2

Unit 1:

1. Describe the 5 arithmetic operators in C.

2. Consider an arithmetic expression where the operands are of different types. What are the rules that apply to such expressions?
[Ans: Consider the expression a + b, where a and b are variables.
(i) If a is floating point and b is double, then float variable is converted into double and the result is in the data type double.
(ii) If a is a floating point variable and b is an int data type, then b is converted into float type and then the expression is evaluated.
(iii) If a is int and b is long int, then a is converted into data type long int before the calculation is done.
]

3. What are the unary operators in C?

4. State the relational operators in C. What is the output an expression containing relational operators? Give appropriate examples.

5. State the logical operators in C. Give appropriate examples.

6. With the help of an examples, explain the use of the conditional operator (ternary operator) in C.

7. With appropriate examples, explain the pre-increment and post-increment operators.

8. With appropriate examples, explain the pre-decrement and post-decrement operators.

9. What are pre-processor directives? Give two pre-processor directives that you have used in C programs.

10. What are library functions in C? Give 5 examples and explain in brief.
Post a Comment