Operators FAQ,Operators Frequently asked questions in C Language

Q4. What are the types of logical operators in C?
We have three major logical operators in C language – logical NOT (!), logical OR (||), and logical AND (&&). The logical NOT (!) operator returns true when the conditions are not satisfied at all. Logical OR (||) operators return true when either or both of the conditions under consideration are met. The logical AND (&&) operator returns true when both the conditions under consideration are met.
Q5. How do math operators differ from other operators in C?
We use arithmetic operations to perform various arithmetic operations on the available operands.
Q6.What are the types of arithmetic operators?
It has various binary and unary operators. The binary operators include +, -, /, *, and %, along with unary operators like ++ and –.
Q7. Can we use both combinations of shift operators - right and left - in our code?
Yes, we can combine shift operators and then use them to extract available data from integer expressions.
Q8. complementary operator flip the entire sequence of code , yes/no?
No


Q9.What is the difference between the less than / greater than operator and the greater than and less than / equal to or equal to operator?
The function of the (<) less than operator is to check whether the first available operand is less than the second. On the other hand, the function of the less than or equal operator (<=) is to check whether the first available operand is less than the second. The same comparison is for the greater than operator and the greater than or equal operator.
For example, 15 < 16 will be true and 15 < 15 will be false. But both 15 <= 16 and 15 <= 15 will be true. Here both 15 < 14 and 15 <= 14 will be incorrect.
Similarly, 17 > 12 will be true and 17 > 17 will be false. But both 17 >= 12 and 17 >= 17 will be true. Here both 17 > 19 and 17 >= 19 will be incorrect.


Q10.Does double equal to operator == work with a single = sign?
No. It's not like that. For the equality operator to work, you must use the == double equals sign.
Q11.Why do we use the comma operator , in C language?
The comma operator is essentially a binary operator that initially operates on the first available operand, removes the result from it, then evaluates the available operands and then returns the result/value accordingly. The comma character in C is mainly used for two different purposes - as an separator and as a opertor. So its behavior varies greatly depending on where we place/use it in the program.
Q12.Why do we use the comma , as a separator?
When we want to declare a large number of variables in any program and provide different arguments in any function, we use a comma as a separator in the program.
e.g,
int p, q, r;
In the above statement, the comma acts as a separator and tells the compiler that the variables p, q, and r are three different types of variables.


Q13.Why do we use the , comma as an operator?
when we want to assign multiple numbers of values to any variable in a C program with the help of a comma (,) We must use the comma in the form of an operator.
For example,
p = 10, 15, 16, 17, 110, 101;
q = (10, 15, 16, 17, 110, 101);
In the first statement above, the value assigned to p will be 10. . It is because the (=) equal to assignment operator has a higher priority as compared to the (,) comma operator. Thus, the program will assign the variable p with a value of 10.
We use commas , as operator when we want to assign a numeric value to any variable in a program using commas.
Q14. Why Ternary ? operator used in C?
The ternary operator in C serves as an alternative syntax for conditional if-else statements. We typically use this operator to summarize long and complex if-else statements. This reduces the number of lines of code while the conditions and statements are small.
Q15. Is ternary operator different from conditional statement?
Ternary operators are essentially a class of conditional operators. They do exactly same function. In simple terms, a specific ternary operator in C is a type of conditional statement used by programmers to make various decisions, which are nothing but conditional statements such as if and else statements. Q16. What is the advantage of using ternary operator over if-else statement?
The ternary operator works similarly to the if/else condition, but changes the overall approach and length of available code. The ternary operator makes the code very easy to understand and looks more professional and algorithmic.
Q17.Why do we use sizeof() operator in C?
We often use the sizeof() operator in C to determine the size of a data type or data specified in the size variable. The sizeof() operator contains just one operand that can either be a cast data type or an expression. Here, the cast refers to the type of information that is surrounded within the parentheses in the program. Note that these data types can be primitive data such as integers and floats, or composite data such as union and structure, or pointer data types.


Previous Topic:-->>Intro C FAQ. || Next topic:-->>Conditional Statements FAQ in C.