Correct Answer: &
Explanation: The & operator is used to perform a bitwise AND operation in C.
Correct Answer: |
Explanation: The | operator is used to perform a bitwise OR operation in C.
Correct Answer: Bitwise XOR
Explanation: The ^ operator is used to perform a bitwise XOR (exclusive OR) operation in C.
Correct Answer: ~
Explanation: The ~ operator is used to invert all the bits (bitwise NOT) in C.
Correct Answer: 1
Explanation: The binary representation of 5 is 101 and 3 is 011. The bitwise AND of these is 001, which is 1 in decimal.
Correct Answer: 7
Explanation: The binary representation of 5 is 101 and 3 is 011. The bitwise OR of these is 111, which is 7 in decimal.
Correct Answer: 6
Explanation: The binary representation of 5 is 101 and 3 is 011. The bitwise XOR of these is 110, which is 6 in decimal.
Correct Answer: Shifts bits to the left
Explanation: The << operator is used to shift bits to the left in C.
Correct Answer: Shifts bits to the right
Explanation: The >> operator is used to shift bits to the right in C.
Correct Answer: -6
Explanation: The bitwise NOT (~) inverts all the bits of 5 (00000101 in binary becomes 11111010 in binary, which is -6 in two’s complement representation).
Correct Answer: 12
Explanation: The binary representation of 6 is 110. Shifting left by 1 bit gives 1100, which is 12 in decimal.
Correct Answer: 3
Explanation: The binary representation of 6 is 110. Shifting right by 1 bit gives 011, which is 3 in decimal.
Correct Answer: ^
Explanation: The ^ operator can be used to toggle specific bits in C.
Correct Answer: 0
Explanation: The binary representation of 8 is 1000 and 4 is 0100. The bitwise AND of these is 0000, which is 0 in decimal.
Correct Answer: 13
Explanation: The binary representation of 9 is 1001 and 4 is 0100. The bitwise OR of these is 1101, which is 13 in decimal.
Correct Answer: 10
Explanation: The binary representation of 15 is 1111 and 5 is 0101. The bitwise XOR of these is 1010, which is 10 in decimal.
Correct Answer: 16
Explanation: The binary representation of 4 is 100. Shifting left by 2 bits gives 10000, which is 16 in decimal.
Correct Answer: 4
Explanation: The binary representation of 32 is 100000. Shifting right by 3 bits gives 100, which is 4 in decimal.
Correct Answer: -1
Explanation: The bitwise NOT (~) inverts all the bits of 0 (00000000 in binary becomes 11111111 in binary, which is -1 in two’s complement representation).
Correct Answer: x | 1
Explanation: The bitwise OR operation x | 1 sets the lowest bit of x to 1.
Correct Answer: 2
Explanation: The binary representation of 3 is 11 and 2 is 10. The bitwise AND of these is 10, which is 2 in decimal.
Correct Answer: &
Explanation: The bitwise AND operation (&) can be used with a mask to clear specific bits to 0 in C.
Correct Answer: 15
Explanation: The binary representation of 10 is 1010 and 5 is 0101. The bitwise OR of these is 1111, which is 15 in decimal.
Correct Answer: 5
Explanation: The binary representation of 7 is 0111 and 2 is 0010. The bitwise XOR of these is 0101, which is 5 in decimal.
Correct Answer: &
Explanation: The bitwise AND operator (&) can be used with a mask to check if a specific bit is set in C.
Correct Answer: 6
Explanation: The binary representation of 14 is 1110 and 7 is 0111. The bitwise AND of these is 0110, which is 6 in decimal.
Correct Answer: 8
Explanation: The binary representation of 1 is 1. Shifting left by 3 bits gives 1000, which is 8 in decimal.
Correct Answer: 4
Explanation: The binary representation of 16 is 10000. Shifting right by 2 bits gives 100, which is 4 in decimal.
Correct Answer: ~x
Explanation: The bitwise NOT operation (~) flips all the bits of the variable x.
Correct Answer: 0
Explanation: The binary representation of 8 is 1000 and 7 is 0111. The bitwise AND of these is 0000, which is 0 in decimal.
Correct Answer: =
Explanation: The = operator is used to assign a value to a variable in C.
Correct Answer: 15
Explanation: The expression x += 5 adds 5 to the current value of x, resulting in 15.
Correct Answer: Subtracts and assigns
Explanation: The -= operator subtracts the right-hand operand from the left-hand operand and assigns the result to the left-hand operand.
Correct Answer: 12
Explanation: The expression x *= 3 multiplies the current value of x by 3, resulting in 12.
Correct Answer: /=
Explanation: The /= operator divides the left-hand operand by the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 1
Explanation: The expression x %= 3 calculates the remainder of x divided by 3, resulting in 1.
Correct Answer: &=
Explanation: The &= operator performs a bitwise AND operation on the left-hand operand with the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 7
Explanation: The binary representation of 5 is 101 and 2 is 010. The bitwise OR operation results in 111, which is 7 in decimal.
Correct Answer: Bitwise XOR and assigns
Explanation: The ^= operator performs a bitwise XOR operation on the left-hand operand with the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 12
Explanation: The binary representation of 3 is 11. Shifting left by 2 bits gives 1100, which is 12 in decimal.
Correct Answer: Shifts bits to the right and assigns
Explanation: The >>= operator shifts the bits of the left-hand operand to the right by the number of positions specified by the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 16
Explanation: The expression x += x adds the value of x to itself, resulting in 16.
Correct Answer: *=
Explanation: The *= operator multiplies the left-hand operand by the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 10
Explanation: The expression x /= 2 divides the current value of x by 2, resulting in 10.
Correct Answer: Modulus and assigns
Explanation: The %= operator calculates the remainder of the division of the left-hand operand by the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 2
Explanation: The binary representation of 6 is 110 and 3 is 011. The bitwise AND operation results in 010, which is 2 in decimal.
Correct Answer: 3
Explanation: The binary representation of 7 is 0111 and 4 is 0100. The bitwise XOR operation results in 0011, which is 3 in decimal.
Correct Answer: 10
Explanation: The binary representation of 5 is 101. Shifting left by 1 bit gives 1010, which is 10 in decimal.
Correct Answer: 4
Explanation: The binary representation of 16 is 10000. Shifting right by 2 bits gives 100, which is 4 in decimal.
Correct Answer: Performs bitwise AND and assigns
Explanation: The &= operator performs a bitwise AND operation on the left-hand operand with the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 10
Explanation: The binary representation of 2 is 0010 and 8 is 1000. The bitwise OR operation results in 1010, which is 10 in decimal.
Correct Answer: |=
Explanation: The |= operator performs a bitwise OR operation on the left-hand operand with the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 6
Explanation: The expression x -= 3 subtracts 3 from the current value of x, resulting in 6.
Correct Answer: Shifts bits to the left and assigns
Explanation: The <<= operator shifts the bits of the left-hand operand to the left by the number of positions specified by the right-hand operand and assigns the result to the left-hand operand.
Correct Answer: 1
Explanation: The expression x /= x divides the current value of x by itself, resulting in 1.
Correct Answer: 0
Explanation: The XOR operation (x ^= x) with the same variable will result in all bits being set to 0, regardless of the initial value of x. Therefore, the result will be 0.
Correct Answer: sizeof
Explanation: The sizeof operator is used to determine the size of a variable or data type in C.
Correct Answer: Evaluates multiple expressions and returns the value of the last expression
Explanation: The comma operator evaluates multiple expressions and returns the value of the last expression.
Correct Answer: Performs conditional operations
Explanation: The ternary operator (?:) evaluates a condition and returns one of two values depending on whether the condition is true or false.
Correct Answer: Returns the memory address of a variable
Explanation: When used as the address-of operator, the & operator returns the memory address of a variable.
Correct Answer: Size of the int data type
Explanation: The sizeof(int) returns the size of the int data type in bytes.
Correct Answer: Separates function arguments
Explanation: The comma operator separates function arguments in a function call.
Correct Answer: Two conditions
Explanation: The ternary operator (?:) requires two conditions, followed by a true and false expression.
Correct Answer: To access memory addresses
Explanation: The & operator, when used as the address-of operator, is used to access memory addresses.
Correct Answer: Size of a data type
Explanation: The sizeof operator returns the size of a data type in bytes.
Correct Answer: Size of the float data type
Explanation: The sizeof(float) returns the size of the float data type in bytes.
Correct Answer: Three expressions
Explanation: The ternary operator (?:) evaluates three expressions: a condition followed by a true and false expression.
Correct Answer: Size of the double data type
Explanation: The sizeof(double) returns the size of the double data type in bytes.
Correct Answer: Declares multiple variables of the same type
Explanation: The comma operator, when used in a declaration, declares multiple variables of the same type.
Correct Answer: Size of the array multiplied by the number of elements
Explanation: The sizeof operator returns the size of the array multiplied by the number of elements in bytes.
Correct Answer: Size of the char data type
Explanation: The sizeof(char) returns the size of the char data type in bytes.
Correct Answer: A single value
Explanation: The ternary operator (?:) returns a single value based on a condition.
Correct Answer: To access memory addresses
Explanation: The & operator, when used as the address-of operator, is used to access memory addresses.
Correct Answer: Size of the pointer
Explanation: The sizeof operator returns the size of the pointer in bytes.
Correct Answer: Declares multiple variables of the same type
Explanation: The comma operator, when used in a declaration, declares multiple variables of the same type.
Correct Answer: The order of evaluation of expressions
Explanation: Operator precedence determines the order in which operators are evaluated in expressions.
Correct Answer: Increment (++)
Explanation: Increment (++) has the highest precedence among the given options.
Correct Answer: Assignment (=)
Explanation: Assignment (=) has the lowest precedence among the given options.
Correct Answer: Left to right
Explanation: The addition operator (+) has left-to-right associativity in C.
Correct Answer: Left to right
Explanation: The ternary operator (?:) has left-to-right associativity in C.
Correct Answer: The order of evaluation of expressions
Explanation: Operator associativity determines the order in which operators of the same precedence are evaluated.
Correct Answer: Assignment (=)
Explanation: Assignment (=) has right-to-left associativity in C.
Correct Answer: Logical AND has higher precedence than logical OR
Explanation: Logical AND (&&) has higher precedence than logical OR (||) in C.
Correct Answer: Left to right
Explanation: The unary prefix increment operator (++) has left-to-right associativity in C.
Correct Answer: None of the above
Explanation: The pointer dereference operator (*) does not have associativity as it’s a unary operator.
int result = 5 + 7 * 3;
Correct Answer: 26
Explanation: According to the operator precedence rules in C, multiplication (*) has higher precedence than addition (+), so 7 * 3 is evaluated first, resulting in 21, then added to 5 to give the final result of 26.
Correct Answer: 2
Explanation: In C, division between two integers truncates any fractional part, so 12 divided by 5 results in 2.
#include <stdio.h>
int main() {
int a = 5;
int b = 2;
printf("%d\n", a / b);
return 0;
}
Correct Answer: 2
Explanation: The integer division of 5 by 2 results in 2, as any fractional part is truncated.
Correct Answer: 4
Explanation: The modulo operator (%) returns the remainder of the division operation. So, 5 % 3 is 2. Then, 2 * 2 is 4.
#include <stdio.h>
int main() {
int x = 10;
int y = ++x;
printf("%d\n", y);
return 0;
}
Correct Answer: 11
Explanation: The pre-increment operator (++x) increments the value of x by 1, so y will be assigned the value of the incremented x, which is 11.
Correct Answer: 0
Explanation: The equality operator (==) returns 1 if the condition is true and 0 if the condition is false. Here, 5 is not equal to 3, so the result is 0.
#include <stdio.h>
int main() {
int x = 5, y = 10, z = 5;
printf("%d\n", x == z);
return 0;
}
Correct Answer: 1
Explanation: The equality operator (==) checks if the values on both sides are equal. Here, x and z both have the value 5, so the expression evaluates to true, which is represented as 1.
Correct Answer: 1
Explanation: The expression !(5 == 3) evaluates to true because 5 is not equal to 3. The logical NOT operator (!) negates the result, so the final result is 1.
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d\n", x > y);
return 0;
}
Correct Answer: 0
Explanation: The greater than operator (>) checks if the left operand is greater than the right operand. Here, x is not greater than y, so the result is false, represented as 0.
Correct Answer: 1
Explanation: The greater than or equal to operator (>=) returns true (1) if the left operand is greater than or equal to the right operand. Here, 5 is equal to 5, so the result is 1.
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d\n", x != y);
return 0;
}
Correct Answer: 1
Explanation: The inequality operator (!=) returns true (1) if the operands are not equal. Here, x is not equal to y, so the result is 1.
Correct Answer: 1
Explanation: The logical AND operator (&&) returns true (1) if both operands are true. Here, both 5 and 3 are non-zero, so the result is 1.
#include <stdio.h>
int main() {
int x = 5, y = 0;
printf("%d\n", x && y);
return 0;
}
Correct Answer: 0
Explanation: In C, the logical AND operator (&&) returns false (0) if any of the operands are false. Here, y is 0, so the result is 0.
Correct Answer: 1
Explanation: The logical OR operator (||) returns true (1) if at least one of the operands is true. Here, both 5 and 3 are non-zero, so the result is 1.
#include <stdio.h>
int main() {
int x = 0, y = 0;
printf("%d\n", x || y);
return 0;
}
Correct Answer: 0
Explanation: In C, the logical OR operator (||) returns true (1) if at least one of the operands is true. Since both x and y are 0 (false), the result is 0.