- What is the difference between the = symbol and == symbol?
The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other hand, the == symbol, also known as “equal to” or “equivalent to”, is a relational operator that is used to compare two values.
- Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
<> is incorrect. While this operator is correctly interpreted as “not equal to” in writing conditional statements, it is not the proper operator to be used in C programming. Instead, the operator! = must be used to indicate “not equal to” condition.
- What is || operator and how does it function in a program?
The || is also known as the OR operator in C programming. When using || to evaluate logical conditions, any condition that evaluates to TRUE will render the entire condition statement as TRUE.
- What is the difference between the expression “++a” and “a++”?
In the first expression, the increment would happen first on variable a, and the resulting value will be the one to be used. This is also known as a prefix increment. In the second expression, the current value of variable a would the one to be used in an operation, before the value of a itself is incremented. This is also known as postfix increment.
- What is the difference between Logical AND and Bitwise AND?
Logical AND (&&): Only used in conjunction with two expressions, to test more than one condition. If both the conditions are true then returns 1.
If false then return 0.
Bitwise AND (&): Only used in bitwise manipulation. It is a Unary operator.
- What is the output of this C code?
#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf(“%d\n”, c);
}
Output:1
- What is the output of this C code?
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf(“x is %d”, x);
}