Integer p, q, r Set p= 3, q =1, r = 2 if(p+ (2&2&2) && q + (3&3&3) && r + (2^2^2)) p = p - 2 q = p Else p = r q = q ^ 2 End if Print p+ q+ r
Answers
Answered by
0
Answer:
Integer a, b, c
Set a = 8, b = 6,c = 4
if(a > b)
a = b
Else
b = a
End if
if(c> b)
c = b
Else
b = c
End if
Print a + b + c
Answered by
1
Answer:
The output of the given code will be 4.
Explanation:
- The first part of the code declares three variables named p, q, and r, and initializes them as p=3, q=1, and r=2.
- After initializing, an if-else loop is used to test the conditions.
- The condition first checks if p+(2&2&2) gives a logic high output. (2&2&2) means bitwise ANDing 2 with itself three times. ANDing any number with itself gives the number itself as the result.
- After the bitwise operation, the result is added to the value of p. If this yields a value greater than zero, then the output of the expression p+(2&2&2) gives a logic high output.
- Similarly, the expressions q + (3&3&3) and r + (2^2^2) are also executed and the outputs obtained are logic high.
- The outputs of these three expressions are logically ANDed meaning that if all three are logic high, then the if statement block will be executed.
- If even any one of the three expressions had logic low output, then the else statement block will be executed.
- Since, the outputs are logic high, the if statement block is executed.
- The value of p is subtracted by 2 and the new value assigned is p=1.
- The value of p is copied to q and the new value is q=1.
- The value of r remains unaltered r=2,
- The else statement block will not be executed.
- The values of p, q, and r are added together. Therefore,
- This final value is then printed.
Therefore, the result of the program is 4.
#SPJ3
Similar questions