C Programming · Unit 3
Operators and Expressions
Exam-focused notes for Operators and Expressions (C Programming, BIT102): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
What this unit covers
- Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
- Conditional operators
- Operator precedence and associativity
- Comma operator
- Expressions and expression evaluation
Operator precedence and associativity
What is operator precedence? Explain assignment and logical operator. [1+4]
--- Operator precedence defines the order (priority) in which operators are evaluated in an expression when multiple operators appear together. An operator with higher precedence is evaluated before an operator with lower precedence. Example: Here, has high...
Full solved answer →What is operator associativity? Explain conditional and Logical operators in brief. [5]
Operator associativity defines the order in which operators of the same precedence are evaluated in an expression when they appear together. There are two types: Type Direction Example Operators ------------------------------------ Left-to-right Evaluated l...
Full solved answer →What is an expression and operator? Discuss operator associativity in C.Write a program to find factorial of a given integer using recursion.[5+5]
--- (a) Expression and Operator An expression in C is a valid combination of operands (variables, constants) and operators that evaluates to a single value. Examples: Expression Type ------ a + b c Arithmetic expression x y Relational expression a = 10 Assi...
Full solved answer →Logical operators
List out different operators in C. Explain Logical and relational operator. [5]
The different types of operators in C are: 1. Arithmetic Operators (+, -, , /, %) 2. Relational Operators (<, , <=, =, ==, !=) 3. Logical Operators (&&, , !) 4. Assignment Operators (=, +=, -=, =, /=) 5. Increment/Decrement Operators (++, --) 6. Bitwise Ope...
Full solved answer →Give any two types of logical operators. What are formatted and unformatted I/O means? [5]
Note: No specific reference notes were found for this topic. The answer below is based on standard C programming curriculum as taught in TU BSc CSIT. --- Logical operators are used to combine or negate conditional expressions and return a true (1) or false ...
Full solved answer →Relational operators
What are relational operators and arithmetic operators? Write a C code to check if a given number is odd or even. [5]
Relational operators are used to compare two values or expressions. They return either true (1) or false (0) based on the comparison. Operator Meaning Example ---------------------------- == Equal to a == b != Not equal to a != b Greater than a b < Less tha...
Full solved answer →Make Unit 3 stick
Practice BIT102 with flashcards & quizzes