Professional Documents
Culture Documents
Lab 3
Lab 3
Spring 2024
Operators
Objective:
1. Develop a clear understanding of basic arithmetic, logic, and assignment operators in C
programming.
Task 1:
Declare two integer variables, “a” and “b”.
Perform addition, subtraction, multiplication, division, and modulus operations on a and
b.
Print the results for each operation.
Hint:
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
% (Modulus - remainder of division)
Code:
Output:
Explanation:
Task 2:
Print your roll number (for example 123), then print it in reverse order (for example 321).
Hint: One of the arithmetic operators can be used.
Code:
Output:
Explanation:
Task 3:
Declare two variables, x and y.
Implement logical AND, OR, and NOT operations on x and y.
Print the results for each operation.
Hint:
&& (Logical AND)
|| (Logical OR)
! (Logical NOT)
Code:
Output:
Explanation:
Task 4:
Declare a variable count and initialize it with 5.
Use assignment operators (+=, -=, *=, /=) to modify the value of count.
Use the increment (++) and decrement (--) operators to modify the value of count.
Print the updated value of count after each operation.
Code:
Output:
Explanation:
Conclusion: