Week 3 Assignment
Week 3 Assignment
Program 1:
Input two integer numbers from keyboard.
Print their binary form.
Try bitwise OR, AND and XOR operations on these two numbers,
and print out the result in both
binary and standard decimal form.
Code:
Output:
Program 2:
Solution:
In case a), the multiplications are evaluated first and then the
addition, leading to the result of 12+30=42
In case b), all the operands are of the same precedence, hence the
expression is evaluated according to associativity from left to
right. Hence the value is 1.
In case c), the parenthesis is evaluated first, and after that all the
operaors have same precedence so they are evaluated left to right.
Hence the answer is 6.
Code:
Output:
Program 4:
Code:
Output: